Skip to content
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

Merged
merged 1 commit into from
Apr 26, 2019

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Apr 17, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

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:

--- 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)

…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)
```
@bflad bflad added bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. labels Apr 17, 2019
@bflad bflad requested a review from a team April 17, 2019 14:34
@ghost ghost added size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Apr 17, 2019
}

// Tags
d.Set("tags", tagsToMap(eni.TagSet))
d.Set("private_ips_count", len(eni.PrivateIpAddresses)-1)
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 👍

@ghost
Copy link

ghost commented Mar 29, 2020

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!

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changing aws_network_interface param private_ips_count has no effect
2 participants