Interview Prep/Python for DevOps/Concurrency, async, tests, services & containers

The scheduled GitHub Actions audit fails with `Error: Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity`.

AdvancedTroubleshootingConcurrency, async, tests, services & containers
Answer

Likely causes → The role trust policy's sub condition does not match the token (wrong repo or branch, or the job uses an environment:, which changes sub to repo:org/repo:environment:prod), the aud is not sts.amazonaws.com, the OIDC provider is missing, or the workflow lacks permissions: id-token: write.

Diagnose → Check the trust policy conditions against the workflow; scheduled runs use the default branch, so sub is repo:org/repo:ref:refs/heads/main.

Fix → Align the token.actions.githubusercontent.com:sub condition (StringLike with the exact pattern), add id-token: write, verify the provider and audience.

Prevent → Keep the trust policy in Terraform next to the workflow; test with workflow_dispatch on main before relying on the schedule.

All Python for DevOps questions Roadmap: Python for automation

More on Concurrency, async, tests, services & containers