Configure OIDC to AWS: provider, role and workflow.
AdvancedConceptOIDC & Security Hardening
Answer
aws iam create-open-id-connect-provider \
--url https://token.actions.githubusercontent.com \
--client-id-list sts.amazonaws.com
aws iam create-role --role-name gha-ecr-push --assume-role-policy-document file://trust.json
permissions:
id-token: write
contents: read
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::111122223333:role/gha-ecr-push
aws-region: ap-south-1
role-session-name: gha-${{ github.run_id }}
- run: aws sts get-caller-identity
AWS validates GitHub's certificate chain itself, so the thumbprint list is no longer meaningful for this issuer (older CLI versions still demand a value).
More on OIDC & Security Hardening
How does GitHub OIDC work, end to end?IntermediateWhat are the `sub` claim formats, and which do you put in an AWS trust policy?AdvancedConfigure OIDC to Azure.AdvancedConfigure OIDC to GCP.AdvancedWhy pin actions to a full commit SHA, and how do you keep pins updated?IntermediateWhat is script injection, and how do you fix it?Advanced