Interview Prep/Terraform/Authentication and Cloud API Errors

EC2 launch fails with `Invalid IAM Instance Profile name` though the instance profile was created seconds before.

BeginnerTroubleshootingAuthentication and Cloud API Errors
Answer

Likely causes → Same eventual consistency for instance profiles; propagation can take several seconds.

Diagnose → aws iam get-instance-profile --instance-profile-name app works when you check later.

Fix → Re-apply. If it recurs, add a time_sleep of 10–15 seconds after the instance profile.

Prevent → Create IAM in a separate, earlier stack for things that are reused.

All Terraform questions

More on Authentication and Cloud API Errors