How does GitHub Actions authenticate to AWS without access keys?
IntermediateConceptIAM Advanced, STS and Multi-Account
Answer
You create an IAM OIDC identity provider for token.actions.githubusercontent.com, a role whose trust policy allows sts:AssumeRoleWithWebIdentity for that provider, and conditions that pin aud and sub to your repo and branch/environment. The workflow requests an OIDC token and the aws-actions/configure-aws-credentials action exchanges it.
"Condition": {
"StringEquals": {"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"},
"StringLike": {"token.actions.githubusercontent.com:sub": "repo:acme/app:ref:refs/heads/main"}
}
The workflow also needs permissions: id-token: write.
More on IAM Advanced, STS and Multi-Account
Explain the IAM policy evaluation logic.AdvancedHow does cross-account access evaluation differ from same-account?AdvancedHow does `sts:AssumeRole` work, step by step?IntermediateWhat is the difference between AssumeRole, AssumeRoleWithWebIdentity and AssumeRoleWithSAML?IntermediateWhat is a permission boundary and when would you use one?IntermediateWhat do Service Control Policies do and not do?Intermediate