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

r/aws_vpc_dhcp_options: fix not found error handling on delete #36933

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Apr 16, 2024

Description

The DeleteDhcpOptions API can return a slightly different error code than the associated read operation. This change introduces a new error code constant, preventing the delete operation from failing if the DHCP options have been deleted out-of-band.

Before:

% make testacc PKG=ec2 TESTS="TestAccVPCDHCPOptions_disappears|TestAccVPCDHCPOptionsAssociation_Disappears_dhcp"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.21.8 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCDHCPOptions_disappears|TestAccVPCDHCPOptionsAssociation_Disappears_dhcp'  -timeout 360m
=== RUN   TestAccVPCDHCPOptionsAssociation_Disappears_dhcp
=== PAUSE TestAccVPCDHCPOptionsAssociation_Disappears_dhcp
=== RUN   TestAccVPCDHCPOptions_disappears
=== PAUSE TestAccVPCDHCPOptions_disappears
=== CONT  TestAccVPCDHCPOptionsAssociation_Disappears_dhcp
=== CONT  TestAccVPCDHCPOptions_disappears
    vpc_dhcp_options_test.go:148: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: deleting EC2 DHCP Options Set (dopt-0afbf75b2cde4f980): InvalidDhcpOptionsID.NotFound: The dhcpOptions ID 'dopt-0afbf75b2cde4f980' does not exist
                status code: 400, request id: fdf420ca-2934-44cd-8d0a-47d4eaceb401

--- FAIL: TestAccVPCDHCPOptions_disappears (10.52s)
=== NAME  TestAccVPCDHCPOptionsAssociation_Disappears_dhcp
    vpc_dhcp_options_association_test.go:76: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: deleting EC2 DHCP Options Set (dopt-0a28e081bb7a4528e): InvalidDhcpOptionsID.NotFound: The dhcpOptions ID 'dopt-0a28e081bb7a4528e' does not exist
                status code: 400, request id: 35937877-857c-4309-b53f-48c8c2ec6dd3

--- FAIL: TestAccVPCDHCPOptionsAssociation_Disappears_dhcp (14.02s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/ec2        19.930s

After:

% make testacc PKG=ec2 TESTS="TestAccVPCDHCPOptions_disappears|TestAccVPCDHCPOptionsAssociation_Disappears_dhcp"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.21.8 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCDHCPOptions_disappears|TestAccVPCDHCPOptionsAssociation_Disappears_dhcp'  -timeout 360m

--- PASS: TestAccVPCDHCPOptions_disappears (10.68s)
--- PASS: TestAccVPCDHCPOptionsAssociation_Disappears_dhcp (14.40s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        20.149s

References

Relates #35747.

Output from Acceptance Testing

% make testacc PKG=ec2 TESTS="TestAccVPCDHCPOptions_"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.21.8 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCDHCPOptions_'  -timeout 360m

--- PASS: TestAccVPCDHCPOptions_disappears (11.88s)
--- PASS: TestAccVPCDHCPOptions_full (13.92s)
--- PASS: TestAccVPCDHCPOptions_basic (13.93s)
--- PASS: TestAccVPCDHCPOptions_tags (27.68s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        33.611s

Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/XS Managed by automation to categorize the size of a PR. service/vpc Issues and PRs that pertain to the vpc service. labels Apr 16, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Apr 16, 2024
The `DeleteDhcpOptions` API can return a slightly different error code
than the associated read operation. This change introduces a new error
code constant, preventing the delete operation from failing if the DHCP
options have been deleted out-of-band.

Before:

```console
% make testacc PKG=ec2 TESTS="TestAccVPCDHCPOptions_disappears|TestAccVPCDHCPOptionsAssociation_Disappears_dhcp"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.21.8 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCDHCPOptions_disappears|TestAccVPCDHCPOptionsAssociation_Disappears_dhcp'  -timeout 360m
=== RUN   TestAccVPCDHCPOptionsAssociation_Disappears_dhcp
=== PAUSE TestAccVPCDHCPOptionsAssociation_Disappears_dhcp
=== RUN   TestAccVPCDHCPOptions_disappears
=== PAUSE TestAccVPCDHCPOptions_disappears
=== CONT  TestAccVPCDHCPOptionsAssociation_Disappears_dhcp
=== CONT  TestAccVPCDHCPOptions_disappears
    vpc_dhcp_options_test.go:148: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: deleting EC2 DHCP Options Set (dopt-0afbf75b2cde4f980): InvalidDhcpOptionsID.NotFound: The dhcpOptions ID 'dopt-0afbf75b2cde4f980' does not exist
                status code: 400, request id: fdf420ca-2934-44cd-8d0a-47d4eaceb401

--- FAIL: TestAccVPCDHCPOptions_disappears (10.52s)
=== NAME  TestAccVPCDHCPOptionsAssociation_Disappears_dhcp
    vpc_dhcp_options_association_test.go:76: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: deleting EC2 DHCP Options Set (dopt-0a28e081bb7a4528e): InvalidDhcpOptionsID.NotFound: The dhcpOptions ID 'dopt-0a28e081bb7a4528e' does not exist
                status code: 400, request id: 35937877-857c-4309-b53f-48c8c2ec6dd3

--- FAIL: TestAccVPCDHCPOptionsAssociation_Disappears_dhcp (14.02s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/ec2        19.930s
```

After:

```console
% make testacc PKG=ec2 TESTS="TestAccVPCDHCPOptions_disappears|TestAccVPCDHCPOptionsAssociation_Disappears_dhcp"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.21.8 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCDHCPOptions_disappears|TestAccVPCDHCPOptionsAssociation_Disappears_dhcp'  -timeout 360m

--- PASS: TestAccVPCDHCPOptions_disappears (10.68s)
--- PASS: TestAccVPCDHCPOptionsAssociation_Disappears_dhcp (14.40s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        20.149s
```

See the AWS EC2 error code reference for additional details:
- https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html#api-error-codes-table-client
@jar-b jar-b force-pushed the b-vpc_dhcp_options-disappears branch from 2ed3c17 to 5f0d2f1 Compare April 16, 2024 14:49
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

@jar-b jar-b merged commit 92ed0a4 into main Apr 16, 2024
52 checks passed
@jar-b jar-b deleted the b-vpc_dhcp_options-disappears branch April 16, 2024 18:10
@github-actions github-actions bot added this to the v5.46.0 milestone Apr 16, 2024
github-actions bot pushed a commit that referenced this pull request Apr 16, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Apr 19, 2024
Copy link

This functionality has been released in v5.46.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. Thank you!

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/vpc Issues and PRs that pertain to the vpc service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants