-
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_security_group: error updating Security Group (sg-xxx): couldn't find resource #21628
Comments
Hey @ialidzhikov 👋 Thank you for taking the time to file this issue. Unfortunately, it looks like the logs you provided cut off some of the more relevant log lines. Would it be possible to include any additional logging around at least the |
Unfortunately, we don't have all logs from the |
Just to add to this, we've seen a notable increase in the number of "eventual consistency" errors when creating security groups in the past few weeks. |
We have been experiencing this issue fairly heavily since late October as well. If there are any sort of logs that would help diagnose the race condition in here I'm happy to help provide them. |
To provide some more information here...we are also seeing presumably this same issue appear when running applies, terraform fails to read existing security group info into state when running a refresh, then tries to create a named security group that already exists, which results in a duplicate error:
|
another form for security groups: resource/aws_security_group: error reading Security Group (sg-xxx): couldn't find resource, |
Comparing our CloudTrail logs to the provider source code, I think I know what's going on here. After creating a new SG, the provider calls terraform-provider-aws/internal/service/ec2/security_group.go Lines 277 to 283 in 9eddee4
Then,
The update method calls off to terraform-provider-aws/internal/service/ec2/security_group.go Lines 408 to 411 in 9eddee4
This subsequent call to There's another eventual consistency bug in creating security groups as well. If this first call to
And this then does nearly the exact same thing as the Update, just with a slightly different error message: terraform-provider-aws/internal/service/ec2/security_group.go Lines 346 to 355 in 9eddee4
So if this last call to Ultimately, these subsequent attempts to read the SG out of AWS shouldn't just assume that they will get a successful response on newly created resources but instead should add retries (or even just skip making these extra AWS API calls and instead reuse the response when verifying the resource was actually created). |
Fix for the bug described in hashicorp#21628 Update default_security_group.go
Fix reading security group right after creation (hashicorp#21628)
This functionality has been released in v3.73.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
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. |
Community Note
Terraform CLI and Terraform AWS Provider Version
terraform version -
0.12.31
provider-aws version -
3.54.0
Affected Resource(s)
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
Debug Output
Panic Output
Expected Behavior
Actual Behavior
Steps to Reproduce
terraform apply
the configuration from aboveMake sure that for heavily used AWS account, it may fail with the above error:
Maybe also cloud provider request limits and throttling can lead to this error?
Can this issue be related to the eventual consistency model of the AWS EC2 API (hence related to #16796)?
Important Factoids
References
The text was updated successfully, but these errors were encountered: