Skip to content

Commit

Permalink
Add test for explicit `aws_vpc_endpoint_private_dns.private_dns_enabl…
Browse files Browse the repository at this point in the history
…ed = false` too.
  • Loading branch information
Alan Ip committed May 26, 2024
1 parent 19ee7c7 commit f14d1b7
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions internal/service/ec2/vpc_endpoint_private_dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,45 @@ func TestAccVPCEndpointPrivateDNS_basic(t *testing.T) {
},
})
}
func TestAccVPCEndpointPrivateDNS_disabled(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}

var endpoint awstypes.VpcEndpoint
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_vpc_endpoint_private_dns.test"
endpointResourceName := "aws_vpc_endpoint.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acctest.PreCheck(ctx, t)
acctest.PreCheckPartitionHasService(t, names.EC2)
},
ErrorCheck: acctest.ErrorCheck(t, names.EC2ServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckVPCEndpointDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVPCEndpointPrivateDNSConfig_disabled(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckVPCEndpointExists(ctx, endpointResourceName, &endpoint),
testAccCheckVPCEndpointPrivateDNSDisabled(ctx, endpointResourceName),
resource.TestCheckResourceAttrPair(endpointResourceName, names.AttrID, resourceName, names.AttrVPCEndpointID),
resource.TestCheckResourceAttr(resourceName, "private_dns_enabled", acctest.CtFalse),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateIdFunc: testAccVPCEndpointPrivateDNSImportStateIdFunc(resourceName),
ImportStateVerify: true,
ImportStateVerifyIdentifierAttribute: names.AttrVPCEndpointID,
},
},
})
}

func TestAccVPCEndpointPrivateDNS_disappears_Endpoint(t *testing.T) {
ctx := acctest.Context(t)
Expand Down Expand Up @@ -235,3 +274,32 @@ resource "aws_vpc_endpoint_private_dns" "test" {
}
`, rName, enabled)
}

func testAccVPCEndpointPrivateDNSConfig_disabled(rName string) string {
return fmt.Sprintf(`
data "aws_region" "current" {}
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"
tags = {
Name = %[1]q
}
}
resource "aws_vpc_endpoint" "test" {
vpc_id = aws_vpc.test.id
service_name = "com.amazonaws.${data.aws_region.current.name}.ec2"
vpc_endpoint_type = "Interface"
tags = {
Name = %[1]q
}
}
resource "aws_vpc_endpoint_private_dns" "test" {
vpc_endpoint_id = aws_vpc_endpoint.test.id
private_dns_enabled = false
}
`, rName)
}

0 comments on commit f14d1b7

Please sign in to comment.