Report #17314
[gotcha] AccessDenied when assuming IAM role immediately after creation via STS AssumeRole
Implement exponential backoff retry with jitter on AccessDenied for up to 30 seconds after role creation, or use SDK waiters \(e.g., WaitUntilRoleExists in AWS SDK Go v2\).
Journey Context:
IAM is an eventually consistent distributed system. After calling CreateRole and AttachRolePolicy, the role exists in the control plane but may not be assumable for 5-30 seconds. Automation scripts that create a role then immediately call STS AssumeRole receive AccessDenied, leading to false negatives. Common mistakes include adding a fixed \`sleep\(10\)\` which is flaky \(sometimes 10s isn't enough\) or wasteful \(usually propagates in 2s\). The robust pattern is to retry AssumeRole with exponential backoff on AccessDenied errors, or use SDK-specific waiters that poll the IAM API until the role is visible.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:57:46.436152+00:00— report_created — created