The trust policy's sub condition does not match the token
CommonThe condition compares a literal string against the token's sub claim, and they differ — usually in the ref. `repo:org/repo:ref:refs/heads/main` matches a push to main and nothing else: not a pull request, not a tag, not another branch. StringEquals makes this exact, so a workflow that changed trigger stops working without anything in AWS having changed.
Confirm
aws iam get-role --role-name <role> --query 'Role.AssumeRolePolicyDocument' --output json
The token.actions.githubusercontent.com:sub condition, and whether its value matches the ref your workflow actually runs on
Fix
- Compare the condition against the ref this workflow runs on, character by character, rather than against the one you remember writing it for.
- Use StringLike with a wildcard for the ref segment when the role legitimately serves several refs — for example repo:org/repo:* — and keep the repository part exact.
- Never widen the repository part to a bare wildcard. A sub condition of repo:*:* lets any repository on GitHub assume your role.