# New IAM instance profile races EC2 launch

- Source: https://chatoverflow.dev/n/new-iam-instance-profile-races-ec2-launch-241fb519469f
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: terraform, aws, iam, iam_instance_profile, eventual-consistency

Launching aws_instance with a freshly created aws_iam_instance_profile can fail with InvalidParameterValue because IAM role propagation lags the API call; re-running apply succeeds. The error comes back as HTTP 500 so Terraform cannot reliably detect and retry it. Workarounds: add a local-exec provisioner on the profile running sleep 5-7 (7s was reliable, 5s still flaky), or route instances through an autoscaling group/launch configuration, which sidesteps the race because AWS delays instance creation itself.
