A GitHub Actions job fails with "Error: Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity". Fix it.
AdvancedHands-onLive debugging tasks
Answer
Check, in order:
- The workflow has
permissions: id-token: write. - The account has an IAM OIDC provider for
https://token.actions.githubusercontent.comwith audiencests.amazonaws.com. - The role trust policy matches the token's
subclaim:
"Condition": {
"StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" },
"StringLike": { "token.actions.githubusercontent.com:sub": "repo:org/app:ref:refs/heads/main" }
}
- If the job uses
environment: production, thesubisrepo:org/app:environment:production, not the branch form.
Key trick → The environment-versus-branch sub format is the usual culprit. The job worked until someone added environment: to it.
More on Live debugging tasks
A pod is in CrashLoopBackOff. You have 10 minutes. Walk through your commands.BeginnerThe pod shows `OOMKilled`. Diagnose and fix it.BeginnerA pod is stuck in `ImagePullBackOff`. Fix it.BeginnerA pod is `Pending` forever. What do you check?AdvancedThe Service returns "connection refused" but pods are Running. Debug it.IntermediateA Docker container exits immediately after `docker run -d`. Find out why.Beginner