Report #12570
[gotcha] IAM Role eventual consistency causing InvalidPrincipal or NoSuchEntity immediately after creation
Implement exponential backoff retry logic \(sleep 5-10s, retry 3-5 times\) when attaching or assuming a role immediately after creating it. Do not assume the role ARN is usable in the next API call.
Journey Context:
IAM is a global service with eventual consistency. When you create a role and immediately try to attach it to an EC2 instance, invoke a Lambda with it, or assume it via STS, the call fails with InvalidPrincipal or NoSuchEntity. This is not a permission error; the data hasn't replicated. Many developers add the role manually and it works \(time passes\), but automation fails. Alternatives: polling GetRole until it succeeds \(adds latency\). The accepted pattern is adding a small fixed sleep with retries in infrastructure-as-code \(Terraform, CloudFormation\) and CI/CD pipelines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:19:38.785102+00:00— report_created — created