-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resource/aws_instance: Retry IAM instance profile (re)association for eventual consistency on update #3055
Conversation
… eventual consistency on update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally 👌 - just one question - can't we start with lower timeout, say 1 minute and raise it if it turns out to be necessary?
…2 minutes to 1 minute initially Generally we would prefer to surface actual IAM issues (bad profile, etc.) sooner rather than later.
Lowered the timeouts to 1 minute to follow our normal practice of preferring to bubble up actual issues sooner rather than later (since EC2 doesn't differentiate between missing vs actually bad here). Can always adjust later if eventual consistency here is really bad (its currently only 30 seconds on instance creation, so we're probably okay). 👍 |
This has been released in terraform-provider-aws version 1.7.1. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
Instance creation could fail with an error like this if the IAM instance profile for the instance was created a short time before run_instances, and had not yet propagated (which happened nearly every time on fast networks): "Instance creation failed => InvalidParameterValue: Value (xxx_profile) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name" We modify ec2.py to use an "EC2Retry" wrapper that inherits from CloudRetry and wraps run_instances, detects the InvalidParameterValue exception with the 'iamInstanceProfile.name is invalid' message, and retries that request a few times. Incidentally, terraform has the same problem and used the same fix, right up to using string matching on the error message to figure out whether it's the right error or not: hashicorp/terraform-provider-aws#3055
Instance creation could fail with an error like this if the IAM instance profile for the instance was created a short time before run_instances, and had not yet propagated (which happened nearly every time on fast networks): "Instance creation failed => InvalidParameterValue: Value (xxx_profile) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name" We modify ec2.py to use an "EC2Retry" wrapper that inherits from CloudRetry and wraps run_instances, detects the InvalidParameterValue exception with the 'iamInstanceProfile.name is invalid' message, and retries that request a few times. Incidentally, terraform has the same problem and used the same fix, right up to using string matching on the error message to figure out whether it's the right error or not: hashicorp/terraform-provider-aws#3055
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Closes #838
Adjusting the existing test for adding
aws_instance.iam_instance_profile
after instance creation by simultaneously creating theaws_iam_instance_profile
instead generates the error reported:After code update (I'll replace with full results shortly):