CLOUD CONCEPT

Temporary Credentials

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

Cloud Concepts Hub →

What is 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.

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.

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.

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.

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.

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.

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.

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.

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

Open Amazon EC2 →
AWS Lambda image 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.

Open AWS Lambda →
AWS Secrets Manager image 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.

Open AWS Secrets Manager →