Sphere
Log in Join
☆ 16

github actions oidc role assume keeps getting accessdenied

Spent most of yesterday on this one. GitHub Actions workflow uses aws-actions/configure-aws-credentials@v4 with OIDC, role ARN arn:aws:iam::123456789012:role/gha-deploy, no static keys. Every job fails with AccessDenied: Not authorized to perform sts:AssumeRoleWithWebIdentity. The role trust policy lists token.actions.githubusercontent.com and has a condition on sub for repo:acme/infra:*. Permissions block in the workflow has id-token: write. What else could be wrong? We have a release going out tonight, so I'd rather not guess at this.

⚑ Report

4 replies

☆ 0
S syn ·2026-10-03#1

Check the aud claim in the trust condition. GitHub's OIDC token uses sts.amazonaws.com as audience by default, but a lot of older trust policies still use sigstore. If the condition doesn't match, the assume fails with exactly that generic AccessDenied. Also check the sub value for your ref, branches and environments produce different strings.

⚑ Report
☆ 0
L lambda ·2026-10-11#2

Trust policy had StringEquals on token.actions.githubusercontent.com:aud set to sigstore. I changed it to sts.amazonaws.com and the error changed to WebIdentityErr: failed to retrieve credentials caused by InvalidIdentityToken: IncorrectOpenIDToken. So progress? Not really. Also check whether the lockfile has peer deps recorded with npm 9 or npm 10 semantics.

⚑ Report
☆ 0
G grpc ·2026-10-22#3

That usually means the sub condition is too narrow. GitHub sends repo:acme/infra:ref:refs/heads/main for a branch build, or repo:acme/infra:environment:production when you use an environment. Wildcards need to match the whole string. Put a temporary StringLike with repo:acme/infra:* just to confirm, then tighten it.

⚑ Report
☆ 0
K k8s ·2026-11-01#4

Once it works, tighten it back. We use StringEquals on sub pinned to repo:acme/infra:environment:production and require the workflow to reference that environment, so pull requests can't assume the deploy role. The broad wildcard is fine for debugging for an hour, not for a production role.

⚑ Report
Log in to reply.