Sub topic 2
How OIDC federation replaces stored secrets
This chapter assumes you know basic GitHub Actions workflows (jobs, steps, triggers), AWS IAM users, roles, and policies, and how to read JSON and YAML. You will learn the working model of OIDC federation. Later chapters build each piece.
The idea in one paragraph
With stored keys, GitHub holds a secret that proves who you are. With OpenID Connect (OIDC) federation, AWS stops asking for a secret. It trusts GitHub to say who is running the job. GitHub signs a short-lived token for each job, and AWS checks the signature and the claims inside the token. If they match a rule you wrote, AWS hands back temporary credentials.
Key terms
- Identity provider (IdP) is a service that signs statements about who a caller is. Here, GitHub is the IdP.
- Federation means AWS accepts an identity that was issued outside AWS.
- Web identity is the AWS name for a caller who proves identity with an OIDC token instead of an IAM user.
- AWS STS (Security Token Service) is the AWS service that issues temporary credentials.
The exchange step by step
- The job asks GitHub for an OIDC token. This works only if the workflow has the
id-token: writepermission. - GitHub returns a signed JSON Web Token (JWT). It describes this exact run: the repository, the branch, and more.
- The job calls
sts:AssumeRoleWithWebIdentitywith the token and the ARN of the role to assume. - STS checks the token's signature against the public keys GitHub publishes. It also confirms that an IAM OIDC provider for GitHub exists in your account.
- STS evaluates the role's trust policy against the token's claims. If the conditions pass, it returns an access key, a secret key, and a session token.
- The job uses those credentials until they expire.
What changes compared with stored keys
| Question | Stored access keys | OIDC federation |
|---|---|---|
| What is saved in GitHub? | Access key ID and secret key | Only a role ARN, which is not secret |
| How long do credentials last? | Until someone rotates them | Minutes to hours, per session |
| Who decides access? | Whoever holds the key | A trust policy matching token claims |
| What if a log leaks? | The key works from anywhere until revoked | The credentials expire soon |
The role ARN is an identifier, not a credential. Someone who learns it cannot use it, because AWS still requires a valid token from GitHub that satisfies the trust policy.
Where the security comes from
The safety depends on the trust policy, not on hiding anything. If the policy accepts any token from GitHub, then any repository on GitHub could assume your role. You must restrict the claims, mainly aud and sub. Later chapters cover this in detail.
Check your understanding
Exercise
A teammate says, "The role ARN is in our workflow file, which is public, so anyone can deploy to our AWS account." Is that correct? Explain what AWS checks before issuing credentials.
Show answer
No. The ARN is only an identifier. STS requires a token signed by GitHub, verifies it against the IAM OIDC provider, and evaluates the role's trust policy against the token's claims (such as aud and sub). A workflow outside the allowed repository or branch gets a rejected AssumeRoleWithWebIdentity call. The real risk is a trust policy that is too broad.