-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Import testing for vpn gateway #9895
Conversation
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.
We should always ensure the entire resource testing is passing. 😄 When running this testing I found two failures:
--- FAIL: TestAccAWSVpnGateway_reattach (47.38s)
testing.go:568: Step 0 error: Check failed: Check 4/6 error: Not found: aws_vpn_gateway.test2
The test configuration needs to have the "bar"
resource names updated.
--- FAIL: TestAccAWSVpnGateway_withAvailabilityZoneSetToState (47.72s)
testing.go:568: Step 1 error: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
(map[string]string) {
}
(map[string]string) (len=1) {
(string) (len=17) "availability_zone": (string) (len=10) "us-west-2a"
}
This one is a little more curious. Generally when we see this, it means the resource Read
function is missing or not calling the d.Set()
for the attribute. The current logic tries to conditionalize this call:
if vpnGateway.AvailabilityZone != nil && *vpnGateway.AvailabilityZone != "" {
d.Set("availability_zone", vpnGateway.AvailabilityZone)
}
In general, this type of conditional shouldn't be necessary, however removing this wouldn't fix the issue here, and in fact does seems required due to the current EC2 API behavior. When setting AvailabilityZone
with CreateVpnGateway
, its not being returned with DescribeVpnGateways
. The EC2 API Reference does mention that it may come back empty, which seems to be the case during the full acceptance test run with the resource.
In this case while less than ideal (we almost always want Terraform to be able to import/perform drift detection), we can use ImportStateVerifyIgnore: []string{"availability_zone"}
in that test to ignore the strange API behavior for now.
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.
LGTM 🚀
--- PASS: TestAccAWSVpnGateway_withAvailabilityZoneSetToState (27.20s)
--- PASS: TestAccAWSVpnGateway_disappears (27.68s)
--- PASS: TestAccAWSVpnGatewayAttachment_basic (30.29s)
--- PASS: TestAccAWSVpnGateway_withAmazonSideAsnSetToState (30.75s)
--- PASS: TestAccAWSVpnGatewayAttachment_deleted (35.93s)
--- PASS: TestAccAWSVpnGateway_tags (38.76s)
--- PASS: TestAccAWSVpnGateway_delete (41.43s)
--- PASS: TestAccAWSVpnGateway_basic (45.22s)
--- PASS: TestAccAWSVpnGateway_reattach (80.59s)
This has been released in version 2.27.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
Relates #8944
Release note for CHANGELOG:
Output from acceptance testing: