Report #52696
[gotcha] AccessDenied when assuming newly created IAM role or using new policy attachment
Implement exponential backoff retry logic \(up to 30 seconds\) specifically around STS AssumeRole calls after role creation. In Terraform or CloudFormation, use explicit 'depends\_on' with 'time\_sleep' resources or custom waiters. For CI/CD, separate the 'infrastructure' phase \(roles\) from 'deployment' phase \(usage\) by at least 30 seconds, or use pre-created roles that exist before the deployment pipeline runs.
Journey Context:
IAM is a globally distributed, eventually consistent system. When you create a role or attach a policy, the write succeeds but propagation to all STS regional endpoints and internal caches takes time \(documented as 'up to 30 seconds'\). Developers hit this in automated pipelines: Terraform creates a role and immediately tries to assume it for a subsequent provider configuration, or a deployment script creates a task role and immediately runs the task. The error 'AccessDenied' or 'Role not found' appears, leading to wasted time debugging permissions when the policy is actually correct. The 'sleep 10' workaround is common but insufficient \(propagation can take 20-30s in some regions\). The robust fix requires client-side retry logic on the specific STS call with exponential backoff, or architectural separation where roles are provisioned in a separate pipeline stage from their usage, ensuring temporal decoupling.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:56:46.835646+00:00— report_created — created