Sub topic 5
Registering GitHub as an IAM OIDC identity provider
This chapter assumes you can run the AWS CLI with administrator-level IAM permissions. It also assumes you know what an IAM role is and have read the earlier chapters on the GitHub OIDC token and its claims.
What the provider does
An IAM OIDC identity provider is an account-level entry that tells AWS to trust tokens from a specific issuer. Here the issuer is GitHub Actions. When a workflow presents a token, AWS STS checks that the token's iss claim matches a registered provider. It also checks the token's signature against the public keys the issuer publishes. Without this entry, STS rejects the token before it reads any role trust policy.
Create the provider
You register the provider once per AWS account. Two values matter: the issuer URL and the client ID list. The client ID is the audience (aud) that tokens must carry. The configure-aws-credentials action requests sts.amazonaws.com by default.
aws iam create-open-id-connect-provider \
--url https://token.actions.githubusercontent.com \
--client-id-list sts.amazonaws.comThe command prints the provider ARN:
arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.comYou will reference this ARN as the Federated principal in the role trust policy in the next chapter.
Verify the registration
List the providers in the account, 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 should show ClientIDList containing sts.amazonaws.com and the URL without the https:// prefix.
Common errors
EntityAlreadyExists: An account can hold only one provider per issuer URL. Another team may have registered GitHub already. Runlist-open-id-connect-providersand reuse the existing ARN. If its client ID list lackssts.amazonaws.com, add it withaws iam add-client-id-to-open-id-connect-provider.AccessDenied: Your identity lacksiam:CreateOpenIDConnectProvider.- A typo in the URL: The URL must match the token's
issclaim exactly, with no trailing slash. A mismatch later shows up as a failedAssumeRoleWithWebIdentitycall.
Exercise
Your teammate runs the create command in a shared account and gets EntityAlreadyExists. What should they do, and why is it not a problem?
Show answer
They should run aws iam list-open-id-connect-providers and reuse the existing provider ARN. An account can have only one provider for token.actions.githubusercontent.com, and every role in the account can share it. Access is controlled by each role's trust policy, not by the provider. They should also check that sts.amazonaws.com is in its client ID list.