Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r/aws_vpc_dhcp_options: fix not found error handling on delete (#36933)
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
- Loading branch information