-
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_network_interface: Refresh private_ips_count into Terraform state and allow updates from 0 to greater than 0 #8353
Conversation
…orm state and allow updates from 0 to greater than 0 Reference: #3210 The Terraform 0.12 Provider SDK acceptance testing was catching that the `private_ips_count` attribute (used to signify _secondary_ private IPs) was not properly being read into the Terraform state during import. Previous output from Terraform 0.12 Provider SDK acceptance testing: ``` --- FAIL: TestAccAWSENI_importBasic (13.57s) 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) "private_ips_count": (string) (len=1) "0" } ``` To fix this particular issue, we prefer to always read this attribute into the Terraform state during `Read`. While looking through previous bug reports for this attribute, came across a report that the resource was not properly updating the count when going from 0 to greater than 0. Added a covering acceptance test and fixed the update logic. Previous output from acceptance testing before `private_ips_count` update logic changes: ``` --- FAIL: TestAccAWSENI_PrivateIpsCount (82.51s) testing.go:568: Step 6 error: Check failed: Check 2/2 error: aws_network_interface.test: Attribute 'private_ips_count' expected "1", got "0" ``` Output from Terraform 0.11 Provider SDK acceptance testing: ``` --- PASS: TestAccAWSENI_computedIPs (33.48s) --- PASS: TestAccAWSENI_sourceDestCheck (35.03s) --- PASS: TestAccAWSENI_disappears (36.04s) --- PASS: TestAccAWSENI_basic (39.30s) --- PASS: TestAccAWSENI_updatedDescription (64.26s) --- PASS: TestAccAWSENI_PrivateIpsCount (90.29s) --- PASS: TestAccAWSENI_ignoreExternalAttachment (119.86s) --- PASS: TestAccAWSENI_attached (257.95s) ``` Output from Terraform 0.12 Provider SDK acceptance testing: ``` --- PASS: TestAccAWSENI_computedIPs (35.09s) --- PASS: TestAccAWSENI_sourceDestCheck (36.54s) --- PASS: TestAccAWSENI_disappears (37.25s) --- PASS: TestAccAWSENI_basic (39.92s) --- PASS: TestAccAWSENI_updatedDescription (64.87s) --- PASS: TestAccAWSENI_PrivateIpsCount (91.51s) --- PASS: TestAccAWSENI_ignoreExternalAttachment (121.11s) --- PASS: TestAccAWSENI_attached (261.48s) ```
} | ||
|
||
// Tags | ||
d.Set("tags", tagsToMap(eni.TagSet)) | ||
d.Set("private_ips_count", len(eni.PrivateIpAddresses)-1) |
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.
Why the need to subtract 1 from the total count?
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.
Information documented on https://www.terraform.io/docs/providers/aws/r/network_interface.html#private_ips_count 👍
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 👍 👍
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
Closes #3210
The Terraform 0.12 Provider SDK acceptance testing was catching that the
private_ips_count
attribute (used to signify secondary private IPs) was not properly being read into the Terraform state during import.Previous output from Terraform 0.12 Provider SDK acceptance testing:
To fix this particular issue, we prefer to always read this attribute into the Terraform state during
Read
. While looking through previous bug reports for this attribute, came across a report that the resource was not properly updating the count when going from 0 to greater than 0. Added a covering acceptance test and fixed the update logic.Previous output from acceptance testing before
private_ips_count
update logic changes:Output from Terraform 0.11 Provider SDK acceptance testing:
Output from Terraform 0.12 Provider SDK acceptance testing: