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.
More on Authentication and Cloud API Errors
`Error: No valid credential sources found` followed by `no EC2 IMDS role found ... context deadline exceeded`.Beginner`Error: Cannot assume IAM Role` — `api error AccessDenied: User: arn:aws:iam::111111111111:user/ci is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::222222222222:role/terraform`.IntermediateGitHub Actions: `Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity`.IntermediateGitHub Actions log says `It looks like you might be trying to authenticate with OIDC. Did you mean to set the id-token permission?`BeginnerApplies that run longer than an hour fail with `ExpiredToken: The security token included in the request is expired`.Intermediate`InvalidClientTokenId: The security token included in the request is invalid.`Beginner