# Temporary Credentials

Temporary credentials are authentication credentials issued with a defined expiration time for limited-duration access to systems and resources.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/temporary-credentials

> Temporary credentials let people and workloads access cloud resources without distributing permanent access keys. They reduce the lifetime of exposed credentials, support federation and role-based access, and shift credential renewal to identity services and supported client libraries.

Practice exams covering Temporary Credentials: [CLF-C02 AWS Certified Cloud Practitioner](https://blowstack.com/practice-exams/aws-certified-cloud-practitioner), [DEA-C01 AWS Certified Data Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional), [AIP-C01 AWS Certified Generative AI Developer - Professional](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional), [MLA-C02 (beta) AWS Certified Machine Learning Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate), [SCS-C03 AWS Certified Security - Specialty](https://blowstack.com/practice-exams/aws-certified-security-specialty), [SAA-C03 AWS Certified Solutions Architect - Associate](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 6 key aspects of Temporary Credentials

Temporary credentials combine bounded lifetimes, role-based permissions, federated or workload authentication, and automated renewal to reduce dependence on permanent secrets.

1. **Explicit expiration**: Credentials stop authenticating new requests after their expiration time. Choose a session duration that fits the task and its risk rather than assuming the longest available duration is appropriate.
2. **Role-based authorization**: A session receives permissions through the assumed role and applicable policy controls. Temporary credentials are not inherently least privilege; an overprivileged role produces an overprivileged session.
3. **Federation and stronger authentication**: People can exchange authenticated identity-provider sessions for temporary cloud access instead of maintaining permanent access keys. Apply MFA at the appropriate authentication boundary and verify that the intended enforcement applies to the access path.
4. **Workload identity**: Instance profiles, task roles, and execution roles let workloads obtain credentials without embedding keys in deployments. Assign separate roles to workloads with different access requirements.
5. **Automatic renewal**: Supported SDK credential providers can retrieve replacement credentials before existing ones expire. Avoid manually copying credentials into static configuration, where renewal will not occur automatically.
6. **Complementary secret management**: Temporary credentials reduce reliance on persistent secrets but do not eliminate database passwords, external API keys, or other required secrets. Manage those separately with secure storage, controlled retrieval, and tested rotation workflows.

## Cloud services for Temporary Credentials

IAM defines who may assume a role and what that role permits, while AWS STS issues the temporary credentials used for access. IAM Identity Center connects workforce authentication to account role sessions. EC2 and Lambda deliver workload-role credentials so applications can use supported SDK credential providers instead of embedded keys. Those applications can then retrieve necessary database passwords or external API secrets from Secrets Manager. This separates cloud identity from application-secret management: role credentials expire and are renewed, while stored secrets follow their own rotation lifecycle. Least-privilege policies, protected credential-delivery paths, and auditing remain necessary across both mechanisms.

- **[Amazon EC2](https://blowstack.com/tools/cloud-services-hub/amazon-ec2)**: Makes temporary role credentials available to instances through instance profiles and the Instance Metadata Service. Supported SDK providers retrieve refreshed credentials automatically; IMDSv2 and metadata-access restrictions help protect the delivery path.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: Provides temporary execution-role credentials to function code for authorized AWS API calls. The execution role governs the function's resource access, while permission to invoke the function is controlled separately.
- **[AWS Secrets Manager](https://blowstack.com/tools/cloud-services-hub/aws-secrets-manager)**: Stores application secrets and supports rotation workflows for credentials that cannot be replaced by workload roles. Applications can use temporary role credentials to retrieve authorized secrets without embedding AWS access keys.

## Temporary Credentials exam questions

Real practice exam questions on Temporary Credentials, with the correct answer and its explanation.

### Question 1 (CLF-C02)

**Question:**

A company runs an on-premises reporting application that obtains temporary AWS credentials through an approved federation process. The application saves the credentials at startup and uses them to read AWS resources. Reports run successfully at first, but later fail because the credentials have expired. The company prohibits storing long-term AWS access keys. Which change will allow the application to continue operating securely?

**Correct answer:** Update the application to obtain fresh credentials from AWS STS through the approved federation process before the current credentials expire.

**Explanation:** AWS STS issues temporary credentials with an expiration time. The application must obtain and use a fresh set of credentials to continue making authenticated requests after the previous set expires.

### Question 2 (MLA-C02 (beta))

**Question:**

An ML evaluation application runs on Amazon EC2 and uses its instance profile credentials to assume a separate role that permits invoking an approved Amazon Bedrock foundation model. Each evaluation takes four hours. The application's AssumeRole request specifies DurationSeconds=14400, but AWS STS rejects the request because the requested session duration exceeds the allowed limit.

The target role's maximum session duration is eight hours. The role's trust policy and the application's permissions are correct. The application uses an SDK credential provider that can automatically renew assumed-role credentials, and its source instance profile credentials refresh automatically. Company policy prohibits long-lived access keys.

Which change will allow the evaluation to run continuously?

**Correct answer:** Request sessions of no more than 3,600 seconds and let the SDK credential provider obtain replacement sessions before expiration.

**Explanation:** The application is using temporary credentials from its instance profile role to assume another role, which is role chaining. Chained role sessions are limited to one hour. A refresh-capable credential provider can obtain successive sessions so the four-hour evaluation continues without long-lived keys.

### Question 3 (SAP-C03)

**Question:**

A company runs processing workers in its data center and in another cloud provider. The workers use IAM Roles Anywhere to obtain credentials for a bootstrap role, and then explicitly call https://sts.amazonaws.com to assume a data-access role. The workers automatically refresh both credential sets.

The company is expanding into an opt-in AWS Region that is already enabled in the account. Credentials returned by the global endpoint work for Amazon S3 requests in a default-enabled Region but fail with an invalid-token error in the opt-in Region. The account is configured for version 1 session tokens from the global endpoint. The data-access role has the required permissions in both Regions.

The company requires each data-access credential set to work in both Regions until expiration. Credential acquisition must not depend on the global AWS STS endpoint, and the company must not change the account-wide global-endpoint token setting. The bootstrap credential mechanism must remain unchanged.

Which solution meets these requirements?

**Correct answer:** Replace the explicitly configured global STS endpoint with an enabled Regional STS endpoint for AssumeRole calls. Continue automatically refreshing the returned credentials and use the same credential set for S3 requests in both Regions.

**Explanation:** Temporary credentials issued by Regional STS endpoints are valid in all AWS Regions, including enabled opt-in Regions. Calling a Regional endpoint also removes the global STS endpoint from the data-access credential acquisition path without changing the account-wide global-endpoint token setting or the bootstrap mechanism.

### Question 4 (DEA-C01)

**Question:**

A data engineering team runs scheduled AWS CLI commands on an Amazon EC2 instance in a development account. The instance has an instance profile containing the DataJobRole IAM role. The commands must read objects by assuming the ProductionDataReadRole role in a production account. ProductionDataReadRole already trusts DataJobRole, and DataJobRole has permission to call sts:AssumeRole on ProductionDataReadRole. The instance metadata service is accessible, and no credentials, environment credentials, or AWS CLI profiles have been configured locally. The team needs the AWS CLI to obtain and refresh the required credentials automatically without scripts that copy credentials. Which configuration meets these requirements?

**Correct answer:** Create a production CLI profile with role_arn set to the ProductionDataReadRole ARN and credential_source set to Ec2InstanceMetadata. Run the commands with --profile production.

**Explanation:** The CLI retrieves DataJobRole credentials from instance metadata and uses them to assume ProductionDataReadRole. The role profile lets the CLI obtain, cache, and refresh temporary role credentials as needed, without storing access keys or using credential-copying scripts.

### Question 5 (AIP-C01)

**Question:**

An enterprise runs document-processing workers that assume a dedicated IAM inference role through AWS STS to invoke an approved Amazon Bedrock model. Each worker caches its role credentials for the session. The inference role permits only the required model invocation operations, and no resource-based policies grant additional access.

During an incident, security discovers that credentials from several inference-role sessions were exposed. All exposed sessions were issued before a known UTC cutoff time. The company must reject every inference-role session issued before that cutoff, even if its credentials have not expired. Workers must continue using the same role ARN and be able to obtain working sessions issued after the cutoff. The requirement must hold after IAM policy changes have propagated.

Which change meets these requirements?

**Correct answer:** Add an explicit deny to the inference role's permissions policy for all actions on all resources when aws:TokenIssueTime is earlier than the cutoff. Have workers discard their cached credentials and assume the role again.

**Explanation:** The explicit deny is evaluated on requests made with the role's temporary credentials. After propagation, sessions issued before the cutoff are denied even if they have not expired. Sessions issued after the cutoff do not match the deny and retain the role's existing limited permissions. Workers can therefore recover by obtaining fresh credentials for the same role.

### Question 6 (DVA-C02)

**Question:**

A developer uses the AWS CLI with an IAM user's long-term access keys to maintain objects in an Amazon S3 bucket. The user's permissions allow the required S3 operations only when aws:MultiFactorAuthPresent is true in the request context. The user has a registered virtual MFA device, but S3 commands currently return AccessDenied. No IAM roles are available for the developer to assume.

Which approach will allow the developer to run the S3 commands without changing the permissions policies?

**Correct answer:** Call AWS STS GetSessionToken with the IAM user's access keys, the MFA device ARN, and a current MFA code. Configure the CLI with the returned access key ID, secret access key, and session token.

**Explanation:** GetSessionToken can authenticate an IAM user's MFA device and issue temporary credentials that carry MFA context. Using all three returned credential components allows the CLI requests to satisfy the policy's MFA condition until the credentials expire.

### Question 7 (SCS-C03)

**Question:**

A company stores confidential customer files in an Amazon S3 bucket under tenant-specific prefixes. A trusted credential broker runs on Amazon EC2 with an instance profile role. The broker authenticates each customer and determines the customer's assigned prefix. Customers must download files directly from S3 by using AWS SDKs.

The company has created one shared download role. Its trust policy permits only the broker's role to assume it. Its permissions policy allows only s3:GetObject on all tenant prefixes. The broker has permission to assume this role. No bucket policies or other policies grant customers additional access.

The broker must issue credentials that expire after 15 minutes and permit downloads only from the authenticated customer's prefix. The solution must not distribute long-term access keys, create a role for each customer, or modify the shared role's policies for each request.

Which implementation meets these requirements?

**Correct answer:** Have the broker call AssumeRole for the shared download role with a 900-second duration and an inline session policy allowing s3:GetObject only on the customer's prefix. Return the access key ID, secret access key, session token, and expiration to the customer.

**Explanation:** AssumeRole supports temporary credentials with a 900-second duration and an inline session policy. The session's effective permissions are the intersection of the role's permissions and the session policy, restricting downloads to the authenticated customer's prefix. The customer must use the session token along with the key pair.

### Question 8 (SAA-C03)

**Question:**

A company migrates a reporting application to Amazon EC2. The application uses a current AWS SDK to upload reports to Amazon S3 and runs continuously for several days. An administrator attaches an instance profile containing an IAM role with the required S3 permissions. However, uploads still fail with AccessDenied. AWS CloudTrail shows that the failed requests use an old IAM user's access key. The application's startup configuration supplies that user's credentials through environment variables.

The company requires the application to stop using long-lived AWS credentials and continue operating when temporary credentials expire. Which solution meets these requirements with the LEAST operational overhead?

**Correct answer:** Remove the IAM user credentials from the application's environment and use the SDK's default credential provider chain to obtain instance profile credentials. Restart the application with the updated configuration, verify access, and deactivate the old access key.

**Explanation:** Without higher-priority static credentials, the default credential provider chain can obtain temporary credentials for the instance profile role. Supported SDK providers automatically refresh these credentials before expiration. Deactivating the old key after verification prevents its continued use.

### Question 9 (DOP-C02)

**Question:**

A company runs Amazon EC2 workers in multiple VPCs. Each worker obtains temporary credentials from its instance profile. Workers make direct AWS API requests through VPC endpoints in their own VPC. Some operations also cause AWS services to make downstream requests through forward access sessions.

A security test shows that credentials copied from an instance can be used from outside its VPC. A DevOps engineer must add an explicit Deny statement to the workload roles that blocks direct API requests made outside the VPC where the credentials were delivered. Direct requests through endpoints in the original VPC must remain permitted by this statement. Forward access sessions and role sessions that did not obtain credentials through an EC2 instance profile must not be blocked by this statement.

The solution must work across all current and future workload VPCs without maintaining VPC ID lists. Existing Allow policies grant the required actions, and no other authorization controls block legitimate requests.

Which Deny statement meets these requirements?

**Correct answer:** {"Effect":"Deny","Action":"*","Resource":"*","Condition":{"StringNotEquals":{"aws:SourceVpc":"${aws:Ec2InstanceSourceVpc}"},"Null":{"ec2:SourceInstanceARN":"false"},"BoolIfExists":{"aws:ViaAWSService":"false"}}}

**Explanation:** aws:Ec2InstanceSourceVpc identifies the VPC where EC2 delivered the instance-role credentials, while aws:SourceVpc identifies the VPC associated with the endpoint used for the current request. StringNotEquals denies requests from another VPC and requests without the endpoint context. The Null condition scopes the Deny to credentials delivered through an EC2 instance profile. The ViaAWSService condition exempts forward access sessions.

## Practice Temporary Credentials in a full exam

Questions on Temporary Credentials in each practice exam, with every answer option and an explanation for each:

- [SAA-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate): 10 questions
- [SCS-C03](https://blowstack.com/practice-exams/aws-certified-security-specialty): 8 questions
- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 8 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 7 questions
- [CLF-C02](https://blowstack.com/practice-exams/aws-certified-cloud-practitioner): 5 questions
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 5 questions
- [MLA-C02 (beta)](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate): 3 questions
- [AIP-C01](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional): 2 questions
- [DEA-C01](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate): 1 question

## What is Temporary Credentials

Temporary credentials are valid for a bounded period rather than until someone explicitly disables or replaces them. An identity service issues them after authenticating a person, validating a federated identity, or establishing that a workload can assume a role. Their permissions determine what the session can do, while their expiration determines how long the credentials remain usable. Short lifetimes reduce exposure after theft, but do not prevent misuse during an active session.

In AWS, temporary API credentials issued by AWS Security Token Service consist of an access key ID, a secret access key, and a session token, together with an expiration time. Requests must include the session token as well as use the key pair for authentication. A missing token can cause authentication failures even when the access key ID and secret access key are correct. Temporary credentials are still secrets: never put them in source code, container images, logs, or public build artifacts.

For human access, federation allows users to authenticate through an identity provider and obtain temporary access instead of receiving individual long-term IAM access keys. IAM Identity Center provides workforce access to AWS accounts through permission sets and role sessions. Multi-factor authentication strengthens authentication, but it is not itself a permission grant or a substitute for temporary credentials. Enforce MFA through the appropriate identity-provider or AWS policy controls rather than assuming that every temporary session proves MFA occurred.

Cross-account access commonly uses role assumption. For example, an engineer authenticated in a development account can assume a troubleshooting role in a production account without creating another IAM user there. The target role's trust policy controls who can assume it, while its permissions policies define allowed actions. Cross-account role assumption normally requires authorization in the caller's account and trust in the target account. Session policies can further restrict access; they cannot expand the role's permissions. Other applicable controls, including explicit denies and organization policies, still apply.

Compute workloads should receive credentials through workload roles. On Amazon EC2, an instance profile associates an IAM role with an instance, and applications can obtain temporary credentials through instance metadata. Require IMDSv2 and restrict metadata access appropriately to reduce credential-exposure risk. AWS Lambda supplies credentials for its execution role to function code. Amazon ECS applications use task roles; the task execution role instead authorizes actions performed by the ECS agent, such as retrieving images or configured secrets. More generally, a service role authorizes an AWS service to act on your behalf, while an execution role supplies the permissions required for a particular workload or execution context.

Supported SDK credential providers retrieve and refresh workload credentials automatically when configured correctly. Applications that manually copy credentials into environment variables or cache them indefinitely can fail when the session expires. Troubleshooting should distinguish expired credentials, missing session tokens, incorrect trust policies, insufficient permissions, clock skew, and a credential provider selecting unintended static keys. Shorter sessions reduce exposure but increase renewal activity and dependence on the credential-issuing path.

Temporary credential renewal differs from secret rotation. AWS Secrets Manager can store application secrets and coordinate supported rotation workflows, such as changing a database password and updating the stored value. Merely storing a long-term IAM access key in a secret does not make it temporary or automatically rotate it. Prefer roles for AWS API access, and use managed secret storage and rotation for credentials that the target system still requires. If temporary credentials are compromised, stop unauthorized issuance and apply appropriate session-revocation or explicit-deny controls; do not assume that disabling the original login invalidates every existing session. Audit role assumptions and subsequent API activity to connect resource access to the responsible person or workload.

## Learn Temporary Credentials in lessons

9 short lessons on Temporary Credentials in 8 certification courses.

- CLF-C02: Temporary Credentials: time-limited AWS access sessions (Premium), https://app.blowstack.com/lessons/temporary-credentials-time-limited-aws-access-sessions-clf-c02
- MLA-C02 (beta): Credential Rotation vs. Temporary Credentials (Premium), https://app.blowstack.com/lessons/credential-rotation-vs-temporary-credentials-mla-c02
- SAP-C03: Temporary Credentials: least-privilege role sessions (Premium), https://app.blowstack.com/lessons/temporary-credentials-least-privilege-role-sessions-sap-c03
- DEA-C01: Temporary Credentials: IAM role sessions (Premium), https://app.blowstack.com/lessons/temporary-credentials-iam-role-sessions-dea-c01
- AIP-C01: Temporary Credentials: least-privilege role sessions (Premium), https://app.blowstack.com/lessons/temporary-credentials-least-privilege-role-sessions-aip-c01
- SCS-C03: Credential Rotation and Temporary Credentials: replacement versus expiration (Premium), https://app.blowstack.com/lessons/credential-rotation-and-temporary-credentials-replacement-versus-expiration-scs-c03
