Sub topic 5
Registering GitHub as an IAM OIDC identity provider
AWS does not trust tokens from GitHub until you tell it to. In this chapter you register GitHub's token issuer as an IAM OIDC identity provider in your AWS account. This is a one-time setup step per account. The role trust policy in the next chapter builds on it.
This chapter assumes you know basic IAM concepts (roles, policies, ARNs), can run the AWS CLI with credentials for an administrator-level identity, and have read the earlier chapters on the GitHub OIDC token and its iss, aud, and sub claims.
What the provider is
An IAM OIDC identity provider is an entry in your account that says: "tokens issued by this URL may be used to ask for role credentials." It stores two things that matter here:
- The issuer URL, which must match the token's
issclaim exactly. For GitHub.com this ishttps://token.actions.githubusercontent.com. - The client ID list, which holds the audience values AWS accepts in the token's
audclaim. For GitHub Actions this issts.amazonaws.com, the default audience thataws-actions/configure-aws-credentialsrequests.
The provider does not grant any permissions. It only makes GitHub a recognized token issuer. Which repositories and branches can use a role is decided later by each role's trust policy.
The provider handles the first two checks. The trust policy handles the third.
Create the provider with the AWS CLI
Run this once in each AWS account that GitHub workflows will deploy to:
aws iam create-open-id-connect-provider \
--url https://token.actions.githubusercontent.com \
--client-id-list sts.amazonaws.comThe command prints the provider ARN:
{
"OpenIDConnectProviderArn": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com"
}Note the format. The ARN is the account ID plus oidc-provider/ plus the issuer URL without https://. You will use this ARN as the Federated principal in role trust policies, so you can also build it yourself without looking it up.
The identity you run this with needs the iam:CreateOpenIDConnectProvider permission. Creating identity providers is an administrative action, so do it from an account administrator or from your infrastructure-as-code pipeline rather than from the deployment role itself.
Thumbprints are no longer required
Older tutorials pass --thumbprint-list 6938fd4d98bab03faadb97b34396831e3780aea1 (or a second GitHub thumbprint). That value is the SHA-1 fingerprint of the top intermediate certificate of GitHub's TLS chain. AWS used it to confirm it was talking to the real GitHub endpoint when fetching the signing keys.
AWS now validates GitHub's OIDC endpoint using its own library of trusted root certificate authorities. For providers like GitHub, whose certificates chain to a trusted CA, the thumbprint is not used for validation. The --thumbprint-list option is optional in current AWS CLI versions, and the CloudFormation ThumbprintList property is optional as well.
Verify the registration
List providers in the account and then inspect the one you created:
aws iam list-open-id-connect-providers
aws iam get-open-id-connect-provider \
--open-id-connect-provider-arn arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.comThe second command returns the URL, the ClientIDList, and any thumbprints. Check that Url is token.actions.githubusercontent.com and that ClientIDList contains sts.amazonaws.com.
Rules and edge cases
- One provider per issuer URL per account. If you run the create command twice, the second call fails with
EntityAlreadyExists. Treat that as success and reuse the existing ARN. All repositories and roles in the account share the one provider. - The provider is regional-free. IAM is a global service, so you create the provider once per account, not once per Region.
- Client IDs are the audience allow-list. If a workflow requests a custom audience, for example
audience: my-custom-audinconfigure-aws-credentials, that value must be in the provider's client ID list. Otherwise AWS rejects the token before it checks any role. You can add one later:
aws iam add-client-id-to-open-id-connect-provider \
--open-id-connect-provider-arn arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com \
--client-id sts.amazonaws.com- The URL must match
issexactly. Theissclaim in GitHub.com tokens ishttps://token.actions.githubusercontent.com, with no trailing slash. A typo creates a provider that never matches. - GitHub Enterprise Server uses a different issuer. Its issuer is
https://HOSTNAME/_services/token, so you register that URL instead. Enterprise Cloud with a custom issuer (enterprise-level OIDC) also uses its own URL, which you can read from a token'sissclaim. - Deleting the provider breaks every role that trusts it. The roles remain, but nothing can assume them through GitHub until you recreate the provider. Because the ARN is derived from the URL, recreating it restores the same ARN and the trust policies work again.
What the provider does not protect against
Registering the provider makes GitHub a trusted issuer for your whole account. GitHub signs tokens for every repository on the platform, including ones you do not own. If a role's trust policy checks only the issuer, any GitHub repository could assume it. Always add aud and sub conditions in the trust policy. AWS now requires the audience condition (and a subject condition for GitHub) when you create a role for this provider in the console, but roles created through the CLI, CloudFormation, or other tools are only as safe as the policy you write.
Checklist
- Confirm the provider does not already exist with
aws iam list-open-id-connect-providers. - Create it with the URL
https://token.actions.githubusercontent.comand client IDsts.amazonaws.com. - Record the ARN. It has the form
arn:aws:iam::ACCOUNT_ID:oidc-provider/token.actions.githubusercontent.com. - Verify it with
get-open-id-connect-provider. - Repeat in every account you deploy to.
Exercise
A teammate runs aws iam create-open-id-connect-provider for GitHub in an account and gets EntityAlreadyExists. They want to delete the existing provider and recreate it with their own settings. Why is that risky, and what should they do first?
Show answer
Every role in the account that trusts the provider relies on it, so deleting it stops all GitHub workflows that assume those roles until a provider is recreated. They should first run aws iam get-open-id-connect-provider with the existing ARN to check its URL and client ID list. If it already has the right URL and contains sts.amazonaws.com, they should reuse it. If only a client ID is missing, they can add it with add-client-id-to-open-id-connect-provider, with no deletion needed.
Exercise
A workflow sets audience: my-custom-aud in configure-aws-credentials, but role assumption fails before any trust policy condition is evaluated. What provider setting is the likely cause, and how do you fix it?
Show answer
The provider's client ID list does not contain my-custom-aud, so AWS rejects the token's aud claim. Fix it by running aws iam add-client-id-to-open-id-connect-provider with --client-id my-custom-aud, and make sure the role's aud condition accepts the same value.