Interview Prep/CI/CD/GitHub Actions Failures

OIDC to AWS fails: `Error: Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity`.

AdvancedTroubleshootingGitHub Actions Failures
Answer

Likely causes → Trust policy sub condition does not match (branch vs environment form); wrong aud; missing id-token: write; the OIDC provider missing in the account.

Diagnose → Print the sub claim your workflow sends (for example repo:org/app:ref:refs/heads/main or repo:org/app:environment:prod) and compare with the role's trust policy:

aws iam get-role --role-name gha-deploy --query 'Role.AssumeRolePolicyDocument'

Fix → Align the StringLike/StringEquals condition with the real sub and aud: sts.amazonaws.com; add permissions: id-token: write.

Prevent → Keep the trust policy in Terraform with tests per environment.

All CI/CD questions

More on GitHub Actions Failures