Cloud concept · Updated

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

In short

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.

Cloud Concepts Hub →

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.

01
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.

02
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.

03
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.

04
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.

05
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.

06
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 EC2Amazon 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 LambdaAWS 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 ManagerAWS 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. Answer them with every option in the exam simulator.

CLF-C02

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?

Show answerCORRECT ANSWER

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

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.

MLA-C02 (beta)

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?

Show answerCORRECT ANSWER

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

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.

SAP-C03

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?

Show answerCORRECT 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.

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.

Practice Temporary Credentials in a full exam

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

Start a free practice exam

What is Temporary Credentials

3 min read

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.

and 3 more lessons

Open the lessons