Skip to content

Commit

Permalink
Configuration changes for 'TestAccAwsDxGatewayAssociation_recreatePro…
Browse files Browse the repository at this point in the history
…posal'.
  • Loading branch information
ewbankkit committed Jul 9, 2021
1 parent 8cb22b4 commit e75ba1b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
10 changes: 0 additions & 10 deletions aws/resource_aws_dx_gateway_association_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,6 @@ func testAccCheckAwsDxGatewayAssociationProposalRecreated(old, new *directconnec
}
}

// func testAccCheckAwsDxGatewayAssociationProposalNotRecreated(old, new *directconnect.GatewayAssociationProposal) resource.TestCheckFunc {
// return func(s *terraform.State) error {
// if old, new := aws.StringValue(old.ProposalId), aws.StringValue(new.ProposalId); old != new {
// return fmt.Errorf("Direct Connect Gateway Association Proposal (%s) recreated (%s)", old, new)
// }

// return nil
// }
// }

func testAccCheckAwsDxGatewayAssociationProposalAccepted(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
Expand Down
32 changes: 29 additions & 3 deletions aws/resource_aws_dx_gateway_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ func TestAccAwsDxGatewayAssociation_allowedPrefixesVpnGatewayCrossAccount(t *tes
func TestAccAwsDxGatewayAssociation_recreateProposal(t *testing.T) {
var providers []*schema.Provider
resourceName := "aws_dx_gateway_association.test"
resourceNameProposal := "aws_dx_gateway_association_proposal.test"
rName := acctest.RandomWithPrefix("tf-acc-test")
rBgpAsn := acctest.RandIntRange(64512, 65534)
var ga1, ga2 directconnect.GatewayAssociation
Expand All @@ -482,13 +481,12 @@ func TestAccAwsDxGatewayAssociation_recreateProposal(t *testing.T) {
),
},
{
Config: testAccDxGatewayAssociationConfig_basicVpnGatewayCrossAccount(rName, rBgpAsn),
Config: testAccDxGatewayAssociationConfig_basicVpnGatewayCrossAccountUpdatedProposal(rName, rBgpAsn),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsDxGatewayAssociationExists(resourceName, &ga2, &gap2),
testAccCheckAwsDxGatewayAssociationNotRecreated(&ga1, &ga2),
testAccCheckAwsDxGatewayAssociationProposalRecreated(&gap1, &gap2),
),
Taint: []string{resourceNameProposal},
},
},
})
Expand Down Expand Up @@ -701,6 +699,34 @@ resource "aws_dx_gateway_association" "test" {
`)
}

func testAccDxGatewayAssociationConfig_basicVpnGatewayCrossAccountUpdatedProposal(rName string, rBgpAsn int) string {
return composeConfig(
testAccDxGatewayAssociationConfigBase_vpnGatewayCrossAccount(rName, rBgpAsn),
`
# Creator
resource "aws_dx_gateway_association_proposal" "test" {
dx_gateway_id = aws_dx_gateway.test.id
dx_gateway_owner_account_id = aws_dx_gateway.test.owner_account_id
associated_gateway_id = aws_vpn_gateway_attachment.test.vpn_gateway_id
}
resource "aws_dx_gateway_association_proposal" "test2" {
dx_gateway_id = aws_dx_gateway.test.id
dx_gateway_owner_account_id = aws_dx_gateway.test.owner_account_id
associated_gateway_id = aws_vpn_gateway_attachment.test.vpn_gateway_id
}
# Accepter
resource "aws_dx_gateway_association" "test" {
provider = "awsalternate"
proposal_id = aws_dx_gateway_association_proposal.test2.id
dx_gateway_id = aws_dx_gateway.test.id
associated_gateway_owner_account_id = data.aws_caller_identity.creator.account_id
}
`)
}

func testAccDxGatewayAssociationConfig_basicTransitGatewaySingleAccount(rName string, rBgpAsn int) string {
return fmt.Sprintf(`
resource "aws_dx_gateway" "test" {
Expand Down

0 comments on commit e75ba1b

Please sign in to comment.