Skip to content

Commit

Permalink
Add 'TestAccEC2InstanceConnectEndpoint_fipsRegion and 'TestAccEC2Inst…
Browse files Browse the repository at this point in the history
…anceConnectEndpoint_nonFIPSRegion'.
  • Loading branch information
ewbankkit committed Dec 27, 2024
1 parent 0f9480b commit ab6575f
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion internal/service/ec2/ec2_instance_connect_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/YakDriver/regexache"
"github.com/hashicorp/aws-sdk-go-base/v2/endpoints"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
Expand Down Expand Up @@ -148,7 +149,6 @@ func TestAccEC2InstanceConnectEndpoint_securityGroupIDs(t *testing.T) {
acctest.MatchResourceAttrRegionalARN(ctx, resourceName, names.AttrARN, "ec2", regexache.MustCompile(`instance-connect-endpoint/.+`)),
resource.TestCheckResourceAttrSet(resourceName, names.AttrAvailabilityZone),
resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName),
resource.TestCheckResourceAttrSet(resourceName, "fips_dns_name"),
acctest.CheckResourceAttrGreaterThanOrEqualValue(resourceName, "network_interface_ids.#", 1),
resource.TestCheckResourceAttr(resourceName, "preserve_client_ip", acctest.CtFalse),
resource.TestCheckResourceAttr(resourceName, "security_group_ids.#", "2"),
Expand All @@ -169,6 +169,60 @@ func TestAccEC2InstanceConnectEndpoint_securityGroupIDs(t *testing.T) {
})
}

func TestAccEC2InstanceConnectEndpoint_fipsRegion(t *testing.T) {
ctx := acctest.Context(t)
resourceName := "aws_ec2_instance_connect_endpoint.test"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsWest2RegionID) },
ErrorCheck: acctest.ErrorCheck(t, names.EC2ServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckInstanceConnectEndpointDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccInstanceConnectEndpointConfig_basic(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckInstanceConnectEndpointExists(ctx, resourceName),
resource.TestCheckResourceAttrSet(resourceName, "fips_dns_name"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccEC2InstanceConnectEndpoint_nonFIPSRegion(t *testing.T) {
ctx := acctest.Context(t)
resourceName := "aws_ec2_instance_connect_endpoint.test"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.ApNortheast1RegionID) },
ErrorCheck: acctest.ErrorCheck(t, names.EC2ServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckInstanceConnectEndpointDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccInstanceConnectEndpointConfig_basic(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckInstanceConnectEndpointExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "fips_dns_name", ""),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccCheckInstanceConnectEndpointExists(ctx context.Context, n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down

0 comments on commit ab6575f

Please sign in to comment.