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_subnet: Refactor to use keyvaluetags library and call Read after Create #10411

Merged
merged 1 commit into from
Oct 25, 2019

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Oct 7, 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

Reference: #7926
Similar in nature to: #10315

Release note for CHANGELOG:

NONE

In preparation for provider-wide ignore and default tag logic, here we refactor this resource to use the consistent keyvaluetags handling. The previous setTags() logic was always performing retries only necessary for resource creation and the resource itself was not following recommended practices to call the Read function after Create.

Output from acceptance testing:

--- PASS: TestAccAWSSubnet_availabilityZoneId (25.22s)
--- PASS: TestAccAWSSubnet_basic (25.66s)
--- PASS: TestAccAWSSubnet_enableIpv6 (41.83s)
--- PASS: TestAccAWSSubnet_ipv6 (66.62s)

…ad after Create

Reference: #7926
Similar in nature to: #10315

In preparation for provider-wide ignore and default tag logic, here we refactor this resource to use the consistent `keyvaluetags` handling. The previous `setTags()` logic was always performing retries only necessary for resource creation and the resource itself was not following recommended practices to call the Read function after Create.

Ouput from acceptance testing:

```
--- PASS: TestAccAWSSubnet_availabilityZoneId (25.22s)
--- PASS: TestAccAWSSubnet_basic (25.66s)
--- PASS: TestAccAWSSubnet_enableIpv6 (41.83s)
--- PASS: TestAccAWSSubnet_ipv6 (66.62s)
```
@bflad bflad requested a review from a team October 7, 2019 16:12
@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/ec2 Issues and PRs that pertain to the ec2 service. labels Oct 7, 2019
@bflad bflad added the technical-debt Addresses areas of the codebase that need refactoring or redesign. label Oct 7, 2019
Copy link
Contributor

@ryndaniels ryndaniels left a comment

Choose a reason for hiding this comment

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

👍

--- PASS: TestAccAWSSubnet_availabilityZoneId (11.09s)
--- PASS: TestAccAWSSubnet_basic (11.09s)
--- PASS: TestAccAWSSubnet_enableIpv6 (17.42s)
--- PASS: TestAccAWSSubnet_ipv6 (24.85s)

@bflad bflad added this to the v2.34.0 milestone Oct 25, 2019
@bflad bflad merged commit f1b17f4 into master Oct 25, 2019
@bflad bflad deleted the td-aws_subnet-keyvaluetags branch October 25, 2019 14:58
bflad added a commit that referenced this pull request Oct 29, 2019
Reference: https://blog.golang.org/go1.13-errors
Reference: #10411

Found via acceptance testing prior to an actual release:

```
--- FAIL: TestAccAWSEMRCluster_basic (19.03s)
    testing.go:615: Step 0 error: errors during apply:

        Error: error adding tags: error tagging resource (subnet-04c4088b2c7f3aa42): InvalidSubnetID.NotFound: The subnet ID 'subnet-04c4088b2c7f3aa42' does not exist
        	status code: 400, request id: 2dafd3b1-ffef-49f9-98e0-1ede0726e8bb
```

Any logic attempting to check the returned AWS Go SDK error code/message from `keyvaluetags` package `UpdateTags` usage will not work since the errors are currently wrapped by value, which was the only option in Go 1.12 and earlier. Go 1.13 introduced the new `%w` verb for `fmt.Errorf()` for wrapping errors, which allows downstream logic to check wrapped error types via `errors.As()`.

Updated via:

```console
$ make gen
```
@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
service/ec2 Issues and PRs that pertain to the ec2 service. size/M Managed by automation to categorize the size of a PR. technical-debt Addresses areas of the codebase that need refactoring or redesign.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants