Skip to content

Commit ddb0bd5

Browse files
authored
r/aws_route53_zone: skip disabling dnssec in unsupported partitions (#33103)
* r/aws_route53_zone: skip disabling dnssec in unsupported partitions * chore: changelog
1 parent 2e72796 commit ddb0bd5

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

.changelog/33103.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
resource/aws_route53_zone: Skip disabling DNS SEC in unsupported partitions
3+
```

internal/service/route53/zone.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ func dnsSECStatus(ctx context.Context, conn *route53.Route53, hostedZoneID strin
445445
output, err = conn.GetDNSSECWithContext(ctx, input)
446446
}
447447

448-
if tfawserr.ErrMessageContains(err, route53.ErrCodeInvalidArgument, "Operation is unsupported for private") {
448+
if tfawserr.ErrMessageContains(err, route53.ErrCodeInvalidArgument, "Operation is unsupported for private") ||
449+
tfawserr.ErrMessageContains(err, "AccessDenied", "The operation GetDNSSEC is not available for the current AWS account") {
449450
return "NOT_SIGNING", nil
450451
}
451452

internal/service/route53/zone_test.go

+54
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,39 @@ func TestAccRoute53Zone_VPC_updates(t *testing.T) {
449449
})
450450
}
451451

452+
// Excercises exception handling during forced destruction in partitions
453+
// which do no support DNSSEC (e.g. GovCloud).
454+
//
455+
// Ref: https://github.com/hashicorp/terraform-provider-aws/issues/22334
456+
func TestAccRoute53Zone_VPC_single_forceDestroy(t *testing.T) {
457+
ctx := acctest.Context(t)
458+
var zone route53.GetHostedZoneOutput
459+
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
460+
resourceName := "aws_route53_zone.test"
461+
vpcResourceName := "aws_vpc.test1"
462+
zoneName := acctest.RandomDomainName()
463+
464+
resource.ParallelTest(t, resource.TestCase{
465+
PreCheck: func() { acctest.PreCheck(ctx, t) },
466+
ErrorCheck: acctest.ErrorCheck(t, route53.EndpointsID),
467+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
468+
CheckDestroy: testAccCheckZoneDestroy(ctx),
469+
Steps: []resource.TestStep{
470+
{
471+
Config: testAccZoneConfig_vpcSingle_forceDestroy(rName, zoneName),
472+
Check: resource.ComposeTestCheckFunc(
473+
testAccCheckZoneExists(ctx, resourceName, &zone),
474+
resource.TestCheckResourceAttr(resourceName, "vpc.#", "1"),
475+
testAccCheckZoneAssociatesVPC(vpcResourceName, &zone),
476+
// Add >100 records to verify pagination works ok
477+
testAccCreateRandomRecordsInZoneID(ctx, &zone, 100),
478+
testAccCreateRandomRecordsInZoneID(ctx, &zone, 5),
479+
),
480+
},
481+
},
482+
})
483+
}
484+
452485
func testAccCheckZoneDestroy(ctx context.Context) resource.TestCheckFunc {
453486
return func(s *terraform.State) error {
454487
conn := acctest.Provider.Meta().(*conns.AWSClient).Route53Conn(ctx)
@@ -706,3 +739,24 @@ resource "aws_route53_zone" "test" {
706739
}
707740
`, rName, zoneName)
708741
}
742+
743+
func testAccZoneConfig_vpcSingle_forceDestroy(rName, zoneName string) string {
744+
return fmt.Sprintf(`
745+
resource "aws_vpc" "test1" {
746+
cidr_block = "10.1.0.0/16"
747+
748+
tags = {
749+
Name = %[1]q
750+
}
751+
}
752+
753+
resource "aws_route53_zone" "test" {
754+
force_destroy = true
755+
name = "%[2]s."
756+
757+
vpc {
758+
vpc_id = aws_vpc.test1.id
759+
}
760+
}
761+
`, rName, zoneName)
762+
}

0 commit comments

Comments
 (0)