Report #36860
[gotcha] Terraform creating IAM role then immediately using it fails with NoSuchEntity
Implement retry logic with exponential backoff \(up to 30s\) for IAM read operations after creation, or use the create response data directly rather than re-querying; never assume immediate consistency.
Journey Context:
IAM is eventually consistent across global regions. When you create a role and immediately attach a policy or assume it, the read may hit a replica that hasn't propagated the write. This manifests as 'NoSuchEntity' or 'InvalidPrincipal' errors in CloudFormation, Terraform, or CI/CD pipelines. The error is transient but breaks automation. The correct fix isn't 'run it again' but implementing idempotent retries on IAM read operations, recognizing this is an architectural constraint of global IAM, not a bug. Some tools like Terraform have built-in retry configurations specifically for this.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T16:20:36.947073+00:00— report_created — created