GitHub Actions OIDC fails: `Not authorized to perform sts:AssumeRoleWithWebIdentity`.
IntermediateTroubleshootingIAM and Access Errors
Answer
Likely causes → Trust policy sub or aud conditions mismatch the workflow's token.
Diagnose →
aws iam get-role --role-name gh-deploy --query Role.AssumeRolePolicyDocument
# in workflow print the token claims with a debug step (never in production logs)
Fix →
- Align
subwithrepo:org/repo:ref:refs/heads/mainor environment form - Ensure
audequalssts.amazonaws.com - Add
id-token: writepermission
Prevent → Test trust policy with a staging branch pattern.
More on IAM and Access Errors
`An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied` for a user who has S3 read access. What is wrong?Beginner`ExpiredToken: The security token included in the request is expired` in a long CI job. How do you fix it?Beginner`User: arn:aws:sts::111111111111:assumed-role/dev/bob is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::222222222222:role/deploy`. Why?Intermediate`An error occurred (AccessDenied) ... because no identity-based policy allows the s3:GetObject action` yet a bucket policy allows the user. Cross-account?IntermediateIAM policy validation: `MalformedPolicyDocument: Policy document should not specify a principal`. What happened?Intermediate`The security token included in the request is invalid` when using `aws` CLI.Beginner