aws_security_group_rule.*: Error finding matching Security Group Rule #5529
Labels
bug
Addresses a defect in current functionality.
service/ec2
Issues and PRs that pertain to the ec2 service.
stale
Old or inactive issues managed by automation, if no further action taken these will get closed.
Community Note
Terraform Version
Affected Resource(s)
(but the same problem can probably occur with many other resources)
Important Factoids
Terraform code is nothing specific. A security group and a security group rule. Looking at the debug log, I found that the following sequence of events occurred within
resource_aws_security_group_rule.go
functionresourceAwsSecurityGroupRuleCreate
sgrule-*
What's really strange and counter intuitive is that the first DescribeSecurityGroups call returns the security group details while the second DescribeSecurityGroups call returns that the group is not found.
This occurs right after security group creation. Investigating this with AWS support, they told me that the API calls are only eventually consistent and this kind of glitches is to be expected until everything in AWS becomes aware of the security group existence :
I believe there is no easy solution to guard against this specific, but this is a bug nonetheless. I don't believe it's possible to retry on every NotFoundError because then we'd reach timeouts hen the resources really do not exists. Perhaps we could have a timestamp telling when a specific resource was created and allow for something like 10s after that to allow retrying in case of NotFoundErrors...
The text was updated successfully, but these errors were encountered: