Federating Identities to Obtain Temporary AWS Credentials
This lesson explains how federation lets people and workloads use an identity they already have, from a corporate directory, a social provider or a CI/CD system, to obtain temporary AWS credentials without IAM users.
Learning outcomes
After completing this lesson, you will be able to:
- Choose a federation option for each kind of user.
- Use session attributes for access control and auditing.
- Identify how workloads obtain temporary credentials on each compute service.
Federation options
Federation lets people and systems use an existing identity to access AWS, instead of creating IAM users. The right mechanism depends on who needs access.
Employees who work in many accounts sign in through IAM Identity Center, connected to the corporate identity provider, such as Microsoft Entra ID or Okta. They get single sign-on to every assigned account and application, and access is managed centrally with permission sets. For a single account or an older setup, an IAM SAML 2.0 or OIDC identity provider in the account lets users assume roles directly.
Customers of an application sign in through Cognito user pools, often with social or enterprise identity providers, and Cognito identity pools exchange their tokens for limited AWS credentials when the application calls AWS directly. CI/CD systems, such as GitHub Actions, use an IAM OIDC identity provider: each job receives a token and exchanges it for short-lived role credentials, so no access keys are stored in the pipeline. The following table summarises the options.
| Who | Federation through | Result |
|---|---|---|
| Employees across many accounts | IAM Identity Center with the corporate IdP | Single sign-on to accounts and applications |
| Users of one account, legacy setups | An IAM SAML 2.0 or OIDC identity provider | AssumeRoleWithSAML or AssumeRoleWithWebIdentity |
| Customers of an application | Cognito user pools and identity pools | Application sign-in and scoped AWS credentials |
| CI/CD systems such as GitHub Actions | An IAM OIDC identity provider | Short-lived role credentials per job, no stored keys |
The following diagram shows the CI/CD case from the table: a GitHub Actions job exchanging an OIDC token for role credentials.

Which federation route?
Session attributes
Federated sessions can carry additional attributes that support access control and auditing. The following list describes these attributes and the related trust policy conditions.
- Session tags passed from the IdP, such as department or project, feed ABAC policies.
- A source identity persists through role chaining, so CloudTrail shows the original person behind every action.
- Trust policies for OIDC providers should restrict the audience and subject claims, such as a specific GitHub repository and branch.
"Condition": {
"StringEquals": {"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"},
"StringLike": {"token.actions.githubusercontent.com:sub": "repo:acme/payments:ref:refs/heads/main"}
}Instance and workload credentials
Workloads obtain temporary credentials in different ways depending on where they run. On Amazon EC2, an instance profile delivers role credentials through the instance metadata service. Instances should require IMDSv2, which needs a session token obtained with a PUT request; this protects the credentials against server-side request forgery (SSRF) attacks, which can usually make only GET requests.
Workloads outside AWS, such as on-premises servers or another cloud, can obtain temporary credentials with IAM Roles Anywhere, which authenticates them with X.509 certificates from a trusted certificate authority. This removes the need to store long-term access keys on those servers.
Workload credentials
Deploying from GitHub Actions without keys
A team stores IAM access keys as GitHub secrets so its workflows can deploy to AWS. The keys are long-lived and shared by every workflow in the repository.
| Step | Action |
|---|---|
| 1 | Create an IAM OIDC identity provider for token.actions.githubusercontent.com |
| 2 | Create a deployment role whose trust policy allows AssumeRoleWithWebIdentity only for the repository's main branch |
| 3 | The workflow requests a short-lived token from GitHub and exchanges it for role credentials |
| 4 | Delete the stored access keys |
Each run now receives credentials valid for about an hour, and a workflow on any other branch or repository is refused by the trust policy's conditions.
Employees sign in with the company's existing identity provider. Which service gives them access to many AWS accounts from one portal?
Show answer
IAM Identity Center, connected to the identity provider through SAML 2.0 and SCIM, with permission sets that define what users can do in each account.
Exam Tips
Remember for the exam
- For CI/CD from GitHub Actions without stored keys, use an OIDC provider with AssumeRoleWithWebIdentity.
- For employee access to many accounts with corporate credentials, use IAM Identity Center.
- To pass department attributes from the identity provider for ABAC, use session tags.
- Require IMDSv2 on EC2 to protect instance credentials.
- For on-premises servers that need temporary AWS credentials without access keys, use IAM Roles Anywhere.