Skip to content

Commit

Permalink
Add 'testAccTransitGatewayVPCAttachment_SecurityGroupReferencingSuppo…
Browse files Browse the repository at this point in the history
…rtV5690Diff'.
  • Loading branch information
ewbankkit committed Sep 27, 2024
1 parent 1c5e2e1 commit d3cf227
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/service/ec2/transitgateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ func TestAccTransitGateway_serial(t *testing.T) {
"DnsSupport": testAccTransitGatewayVPCAttachment_DNSSupport,
"Ipv6Support": testAccTransitGatewayVPCAttachment_IPv6Support,
"SecurityGroupReferencingSupport": testAccTransitGatewayVPCAttachment_SecurityGroupReferencingSupport,
"SharedTransitGateway": testAccTransitGatewayVPCAttachment_SharedTransitGateway,
"SubnetIds": testAccTransitGatewayVPCAttachment_SubnetIDs,
"TransitGatewayDefaultRouteTableAssociation": testAccTransitGatewayVPCAttachment_TransitGatewayDefaultRouteTableAssociation,
"SecurityGroupReferencingSupportV5690Diff": testAccTransitGatewayVPCAttachment_SecurityGroupReferencingSupportV5690Diff,
"SharedTransitGateway": testAccTransitGatewayVPCAttachment_SharedTransitGateway,
"SubnetIds": testAccTransitGatewayVPCAttachment_SubnetIDs,
"TransitGatewayDefaultRouteTableAssociation": testAccTransitGatewayVPCAttachment_TransitGatewayDefaultRouteTableAssociation,
"TransitGatewayDefaultRouteTableAssociationAndPropagationDisabled": testAccTransitGatewayVPCAttachment_TransitGatewayDefaultRouteTableAssociationAndPropagationDisabled,
"TransitGatewayDefaultRouteTablePropagation": testAccTransitGatewayVPCAttachment_TransitGatewayDefaultRouteTablePropagation,
},
Expand Down
71 changes: 71 additions & 0 deletions internal/service/ec2/transitgateway_vpc_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ import (
awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-plugin-testing/statecheck"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
tfplancheck "github.com/hashicorp/terraform-provider-aws/internal/acctest/plancheck"
tfstatecheck "github.com/hashicorp/terraform-provider-aws/internal/acctest/statecheck"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
tfsync "github.com/hashicorp/terraform-provider-aws/internal/experimental/sync"
tfec2 "github.com/hashicorp/terraform-provider-aws/internal/service/ec2"
Expand Down Expand Up @@ -253,6 +259,71 @@ func testAccTransitGatewayVPCAttachment_SecurityGroupReferencingSupport(t *testi
})
}

// https://github.com/hashicorp/terraform-provider-aws/issues/39518.
// Resources created at <= v5.58.0 show drift after upgrade to v5.69.0.
func testAccTransitGatewayVPCAttachment_SecurityGroupReferencingSupportV5690Diff(t *testing.T, semaphore tfsync.Semaphore) {
ctx := acctest.Context(t)
var transitGatewayVpcAttachment awstypes.TransitGatewayVpcAttachment
resourceName := "aws_ec2_transit_gateway_vpc_attachment.test"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckTransitGatewaySynchronize(t, semaphore)
acctest.PreCheck(ctx, t)
testAccPreCheckTransitGatewayVPCAttachment(ctx, t)
},
ErrorCheck: acctest.ErrorCheck(t, names.EC2ServiceID),
CheckDestroy: testAccCheckTransitGatewayVPCAttachmentDestroy(ctx),
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
"aws": {
Source: "hashicorp/aws",
VersionConstraint: "5.68.0",
},
},
Config: testAccTransitGatewayVPCAttachmentConfig_basic(rName),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate),
},
},
ConfigStateChecks: []statecheck.StateCheck{
tfstatecheck.ExpectNoValue(resourceName, tfjsonpath.New("security_group_referencing_support")),
},
Check: resource.ComposeTestCheckFunc(
testAccCheckTransitGatewayVPCAttachmentExists(ctx, resourceName, &transitGatewayVpcAttachment),
),
},
{
ExternalProviders: map[string]resource.ExternalProvider{
"aws": {
Source: "hashicorp/aws",
VersionConstraint: "5.69.0",
},
},
Config: testAccTransitGatewayVPCAttachmentConfig_basic(rName),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate),
tfplancheck.ExpectKnownValueChange(resourceName, tfjsonpath.New("security_group_referencing_support"), knownvalue.StringExact(string(awstypes.SecurityGroupReferencingSupportValueEnable)), knownvalue.StringExact(string(awstypes.SecurityGroupReferencingSupportValueDisable))),
},
PostApplyPostRefresh: []plancheck.PlanCheck{
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
},
},
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("security_group_referencing_support"), knownvalue.StringExact(string(awstypes.SecurityGroupReferencingSupportValueDisable))),
},
Check: resource.ComposeTestCheckFunc(
testAccCheckTransitGatewayVPCAttachmentExists(ctx, resourceName, &transitGatewayVpcAttachment),
),
},
},
})
}

func testAccTransitGatewayVPCAttachment_SharedTransitGateway(t *testing.T, semaphore tfsync.Semaphore) {
ctx := acctest.Context(t)
var transitGatewayVpcAttachment1 awstypes.TransitGatewayVpcAttachment
Expand Down

0 comments on commit d3cf227

Please sign in to comment.