@@ -449,6 +449,39 @@ func TestAccRoute53Zone_VPC_updates(t *testing.T) {
449
449
})
450
450
}
451
451
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
+
452
485
func testAccCheckZoneDestroy (ctx context.Context ) resource.TestCheckFunc {
453
486
return func (s * terraform.State ) error {
454
487
conn := acctest .Provider .Meta ().(* conns.AWSClient ).Route53Conn (ctx )
@@ -706,3 +739,24 @@ resource "aws_route53_zone" "test" {
706
739
}
707
740
` , rName , zoneName )
708
741
}
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