-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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_vpc: Handle read-after-create eventual consistency #18391
Conversation
Reference: #16796 Output from acceptance testing in AWS Commercial: ``` --- PASS: TestAccAWSVpc_AssignGeneratedIpv6CidrBlock (82.88s) --- PASS: TestAccAWSVpc_basic (41.94s) --- PASS: TestAccAWSVpc_bothDnsOptionsSet (50.15s) --- PASS: TestAccAWSVpc_classiclinkDnsSupportOptionSet (42.24s) --- PASS: TestAccAWSVpc_classiclinkOptionSet (42.26s) --- PASS: TestAccAWSVpc_coreMismatchedDiffs (29.27s) --- PASS: TestAccAWSVpc_defaultAndIgnoreTags (62.73s) --- PASS: TestAccAWSVpc_defaultTags_providerAndResource_duplicateTag (4.83s) --- PASS: TestAccAWSVpc_defaultTags_providerAndResource_nonOverlappingTag (70.21s) --- PASS: TestAccAWSVpc_defaultTags_providerAndResource_overlappingTag (69.97s) --- PASS: TestAccAWSVpc_defaultTags_providerOnly (65.84s) --- PASS: TestAccAWSVpc_defaultTags_updateToProviderOnly (55.23s) --- PASS: TestAccAWSVpc_defaultTags_updateToResourceOnly (50.23s) --- PASS: TestAccAWSVpc_DisabledDnsSupport (49.90s) --- PASS: TestAccAWSVpc_disappears (22.42s) --- PASS: TestAccAWSVpc_ignoreTags (64.60s) --- PASS: TestAccAWSVpc_tags (82.89s) --- PASS: TestAccAWSVpc_Tenancy (84.83s) --- PASS: TestAccAWSVpc_update (67.73s) ``` Output from acceptance testing in AWS GovCloud (US): ``` --- PASS: TestAccAWSVpc_AssignGeneratedIpv6CidrBlock (85.77s) --- PASS: TestAccAWSVpc_basic (36.99s) --- PASS: TestAccAWSVpc_bothDnsOptionsSet (48.65s) --- PASS: TestAccAWSVpc_coreMismatchedDiffs (32.11s) --- PASS: TestAccAWSVpc_defaultAndIgnoreTags (63.25s) --- PASS: TestAccAWSVpc_defaultTags_providerAndResource_duplicateTag (4.70s) --- PASS: TestAccAWSVpc_defaultTags_providerAndResource_nonOverlappingTag (59.36s) --- PASS: TestAccAWSVpc_defaultTags_providerAndResource_overlappingTag (59.09s) --- PASS: TestAccAWSVpc_defaultTags_providerOnly (60.21s) --- PASS: TestAccAWSVpc_defaultTags_updateToProviderOnly (46.79s) --- PASS: TestAccAWSVpc_defaultTags_updateToResourceOnly (48.55s) --- PASS: TestAccAWSVpc_DisabledDnsSupport (47.71s) --- PASS: TestAccAWSVpc_disappears (23.64s) --- PASS: TestAccAWSVpc_ignoreTags (62.21s) --- PASS: TestAccAWSVpc_tags (82.23s) --- PASS: TestAccAWSVpc_Tenancy (83.42s) --- PASS: TestAccAWSVpc_update (66.22s) --- SKIP: TestAccAWSVpc_classiclinkDnsSupportOptionSet (15.15s) --- SKIP: TestAccAWSVpc_classiclinkOptionSet (15.15s) ```
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.
One comment on where to handle not found cases, otherwise LGTM 🚀
--- PASS: TestAccAWSVpc_coreMismatchedDiffs (36.32s)
--- PASS: TestAccAWSVpc_basic (19.26s)
--- PASS: TestAccAWSVpc_disappears (15.60s)
--- PASS: TestAccAWSVpc_defaultTags_updateToProviderOnly (31.35s)
--- PASS: TestAccAWSVpc_defaultTags_updateToResourceOnly (32.73s)
--- PASS: TestAccAWSVpc_defaultTags_providerAndResource_duplicateTag (2.57s)
--- PASS: TestAccAWSVpc_defaultTags_providerOnly (39.58s)
--- PASS: TestAccAWSVpc_defaultTags_providerAndResource_nonOverlappingTag (39.89s)
--- PASS: TestAccAWSVpc_defaultTags_providerAndResource_overlappingTag (41.59s)
--- PASS: TestAccAWSVpc_ignoreTags (42.45s)
--- PASS: TestAccAWSVpc_defaultAndIgnoreTags (43.62s)
--- PASS: TestAccAWSVpc_AssignGeneratedIpv6CidrBlock (56.14s)
--- PASS: TestAccAWSVpc_Tenancy (62.82s)
--- PASS: TestAccAWSVpc_tags (60.47s)
--- PASS: TestAccAWSVpc_bothDnsOptionsSet (37.67s)
--- PASS: TestAccAWSVpc_DisabledDnsSupport (37.29s)
--- PASS: TestAccAWSVpc_update (46.65s)
--- PASS: TestAccAWSVpc_classiclinkOptionSet (25.24s)
--- PASS: TestAccAWSVpc_classiclinkDnsSupportOptionSet (24.06s)
if d.IsNewResource() && tfawserr.ErrCodeEquals(err, "InvalidVpcID.NotFound") { | ||
return resource.RetryableError(err) | ||
} | ||
|
||
if err != nil { | ||
return resource.NonRetryableError(err) | ||
} | ||
|
||
if d.IsNewResource() && vpc == nil { | ||
return resource.RetryableError(&resource.NotFoundError{ | ||
LastError: fmt.Errorf("EC2 VPC (%s) not found", d.Id()), | ||
}) | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
if tfresource.TimedOut(err) { | ||
vpc, err = finder.VpcByID(conn, d.Id()) | ||
} | ||
|
||
if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, "InvalidVpcID.NotFound") { | ||
log.Printf("[WARN] EC2 VPC (%s) not found, removing from state", d.Id()) | ||
d.SetId("") | ||
return nil | ||
} |
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.
If finder.VpcByID()
returns a resource.NotFoundError
when the VPC is not found, we'd have to do a lot less checking for different not found cases at this level.
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.
In general, this is likely a good move, but it is not the current standard, I am not immediately sure of all the implications, and I don't feel comfortable implementing it my own without discussing it first. I have created two tracking issues for following up to this:
This has been released in version 3.34.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 for triage. Thanks! |
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! |
Community Note
Reference: #16796
Output from acceptance testing in AWS Commercial:
Output from acceptance testing in AWS GovCloud (US):