Temporary Security Credentials
You can use the AWS Security Token Service (AWS STS) to create and provide trusted users with temporary security credentials that can control access to your AWS resources. Temporary security credentials work almost identically to the long-term access key credentials that your IAM users can use, with the following differences:
Temporary security credentials are short-term, as the name implies. They can be configured to last for anywhere from a few minutes to several hours. After the credentials expire, AWS no longer recognizes them or allows any kind of access from API requests made with them.
Temporary security credentials are not stored with the user but are generated dynamically and provided to the user when requested. When (or even before) the temporary security credentials expire, the user can request new credentials, as long as the user requesting them still has permissions to do so.
These differences lead to the following advantages for using temporary credentials:
You do not have to distribute or embed long-term AWS security credentials with an application.
You can provide access to your AWS resources to users without having to define an AWS identity for them. Temporary credentials are the basis for roles and identity federation.
The temporary security credentials have a limited lifetime, so you do not have to rotate them or explicitly revoke them when they're no longer needed. After temporary security credentials expire, they cannot be reused. You can specify how long the credentials are valid, up to a maximum limit.
AWS STS and AWS Regions
Temporary security credentials are generated by AWS STS. By default, AWS STS is a global
service that has a single endpoint at
https://sts.amazonaws.com. By default,
AWS STS has one regional endpoint available at
You can enable AWS STS in additional regions for your account and then make AWS STS API calls to
endpoints in those added regions. This can reduce latency (server lag) by sending the requests
to servers in a region that is geographically closer to you. No matter which region your
credentials come from, they work globally. For more information, see Activating AWS STS in a New Region.
Common Scenarios for Temporary Credentials
Temporary credentials are useful in scenarios that involve identity federation, delegation, cross-account access, and IAM roles.
You can manage your user identities in an external system outside of AWS and grant users who sign in from those systems access to perform AWS tasks and access your AWS resources. IAM supports two types of identity federation. In both cases, the identities are stored outside of AWS. The distinction is where the external system resides—in your data center or an external third party on the web. For more information about external identity providers, see Identity Providers and Federation.
Enterprise identity federation – You can authenticate users in your organization's network, and then provide those users access to AWS without creating new AWS identities for them and requiring them to sign in with a separate user name and password. This is known as the single sign-on (SSO) approach to temporary access. AWS STS supports open standards like Security Assertion Markup Language (SAML) 2.0, with which you can use Microsoft AD FS to leverage your Microsoft Active Directory. You can also use SAML 2.0 to manage your own solution for federating user identities. For more information, see About SAML 2.0-based Federation.
Custom federation broker – You can use your organization's authentication system to grant access to AWS resources. For an example scenario, see Creating a URL that Enables Federated Users to Access the AWS Management Console (Custom Federation Broker).
Federation using SAML 2.0 – You can use your organization's authentication system and SAML to grant access to AWS resources. For more information and an example scenario, see About SAML 2.0-based Federation.
Web identity federation – You can let users sign in using a well-known third party identity provider such as Login with Amazon, Facebook, Google, or any OpenID Connect (OIDC) 2.0 compatible provider. You can exchange the credentials from that provider for temporary permissions to use resources in your AWS account. This is known as the web identity federation approach to temporary access. When you use web identity federation for your mobile or web application, you don't need to create custom sign-in code or manage your own user identities. Using web identity federation helps you keep your AWS account secure, because you don't have to distribute long-term security credentials, such as IAM user access keys, with your application. For more information, see About Web Identity Federation.
AWS STS web identity federation supports Login with Amazon, Facebook, Google, and any OpenID Connect (OICD)-compatible identity provider.
For mobile applications, we recommend that you use Amazon Cognito. You can use this service with the AWS Mobile SDK for iOS and the AWS Mobile SDK for Android and Fire OS to create unique identities for users and authenticate them for secure access to your AWS resources. Amazon Cognito supports the same identity providers as AWS STS, and also supports unauthenticated (guest) access and lets you migrate user data when a user signs in. Amazon Cognito also provides APIs for synchronizing user data so that it is preserved as users move between devices. For more information, see the following:
Roles for Cross-account Access
Many organizations maintain more than one AWS account. Using roles and cross-account access, you can define user identities in one account, and use those identities to access AWS resources in other accounts that belong to your organization. This is known as the delegation approach to temporary access. For more information, see Creating a Role to Delegate Permissions to an IAM User.
Roles for Amazon EC2
If you run applications on Amazon EC2 instances and those applications need access to AWS resources, you can provide temporary security credentials to your instances when you launch them. These temporary security credentials are available to all applications that run on the instance, so you don't need to store any long-term credentials on the instance. For more information, see Using an IAM Role to Grant Permissions to Applications Running on Amazon EC2 Instances.
Other AWS Services
You can use temporary security credentials to access most AWS services. For a list of the services that accept temporary security credentials, see AWS Services That Work with IAM.