Skip to content

Commit

Permalink
service/directconnect: vpn_gateway_id Argument Removals and Increase …
Browse files Browse the repository at this point in the history
…aws_dx_gateway_association Default Timeouts (#14144)

* resource/aws_dx_gateway_association: Increase default create/update/delete timeouts to 30 minutes

Previously, we were seeing consistent failures across many of acceptance tests:

```
    TestAccAwsDxGatewayAssociation_allowedPrefixesVpnGatewaySingleAccount: testing.go:684: Step 1 error: errors during apply:

        Error: error waiting for Direct Connect gateway association (ga-a59d30b3-e6de-435e-bb17-cd7ed23f400evgw-06bccd6488d2b8d87) to become available: timeout while waiting for state to become 'associated' (last state: 'updating', timeout: 10m0s)

    TestAccAwsDxGatewayAssociation_allowedPrefixesVpnGatewayCrossAccount: testing.go:684: Step 1 error: errors during apply:

        Error: error waiting for Direct Connect gateway association (ga-a8b1b976-c0a1-4b64-8560-9d9cc45d11a3vgw-0a2e52679acf9c250) to become available: timeout while waiting for state to become 'associated' (last state: 'updating', timeout: 10m0s)

--- FAIL: TestAccAwsDxGatewayAssociation_basicTransitGatewaySingleAccount (989.81s)
testing.go:684: Step 0 error: errors during apply:
Error: error waiting for Direct Connect gateway association (ga-48d0e3d3-e131-443d-9693-e64eff519baatgw-0a2a0ea77f65ed202) to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 15m0s)

--- FAIL: TestAccAwsDxGatewayAssociation_basicTransitGatewayCrossAccount (991.80s)
testing.go:684: Step 0 error: errors during apply:
Error: error waiting for Direct Connect gateway association (ga-9f9c1ed2-97b6-41c5-8018-0724f6162b59tgw-06f7ce56df96282d7) to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 15m0s)

--- FAIL: TestAccAwsDxGatewayAssociation_basicVpnGatewaySingleAccount (1816.92s)
testing.go:684: Step 0 error: errors during apply:
Error: error waiting for Direct Connect gateway association (ga-76c9d0f4-b0aa-4b1b-96d9-10ce8c3ca025vgw-0c47a2c63baf7d4d8) to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 15m0s)

testing.go:745: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.
Error: errors during apply: error waiting for Direct Connect gateway association (ga-76c9d0f4-b0aa-4b1b-96d9-10ce8c3ca025vgw-0c47a2c63baf7d4d8) to be deleted: timeout while waiting for state to become 'disassociated, deleted' (last state: 'disassociating', timeout: 15m0s)

--- FAIL: TestAccAwsDxGatewayAssociation_allowedPrefixesVpnGatewaySingleAccount (1816.89s)
testing.go:684: Step 0 error: errors during apply:
Error: error waiting for Direct Connect gateway association (ga-12a5c1e8-322e-4bc1-8a5a-f4b778a00db3vgw-09c811d121256131b) to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 15m0s)

testing.go:745: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.
Error: errors during apply: error waiting for Direct Connect gateway association (ga-12a5c1e8-322e-4bc1-8a5a-f4b778a00db3vgw-09c811d121256131b) to be deleted: timeout while waiting for state to become 'disassociated, deleted' (last state: 'disassociating', timeout: 15m0s)

--- FAIL: TestAccAwsDxGatewayAssociation_allowedPrefixesVpnGatewayCrossAccount (1819.25s)
testing.go:684: Step 0 error: errors during apply:
Error: error waiting for Direct Connect gateway association (ga-ccf678f2-5d51-441e-86c5-308c731f26abvgw-063e75f539bc3719c) to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 15m0s)

testing.go:745: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.
Error: errors during apply: error waiting for Direct Connect gateway association (ga-ccf678f2-5d51-441e-86c5-308c731f26abvgw-063e75f539bc3719c) to be deleted: timeout while waiting for state to become 'disassociated, deleted' (last state: 'disassociating', timeout: 15m0s)

--- FAIL: TestAccAwsDxGatewayAssociation_multiVpnGatewaysSingleAccount (2487.01s)
testing.go:684: Step 0 error: errors during apply:
Error: error waiting for Direct Connect gateway association (ga-5d93ccd0-8344-4ee6-95f8-58af27e01301vgw-054e2b0e7ecf45c8d) to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 15m0s)

Error: error waiting for Direct Connect gateway association (ga-5d93ccd0-8344-4ee6-95f8-58af27e01301vgw-057b39dbec7338ec1) to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 15m0s)

testing.go:745: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.
Error: errors during apply: error waiting for Direct Connect gateway association (ga-5d93ccd0-8344-4ee6-95f8-58af27e01301vgw-057b39dbec7338ec1) to be deleted: timeout while waiting for state to become 'disassociated, deleted' (last state: 'disassociating', timeout: 15m0s)

--- FAIL: TestAccAwsDxGatewayAssociation_basicVpnGatewayCrossAccount (2529.42s)
testing.go:684: Step 0 error: errors during apply:
Error: error waiting for Direct Connect gateway association (ga-ad8143a9-657e-4ed2-9ebb-a78dd2bee2c1vgw-0d552249edec48941) to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 15m0s)

testing.go:745: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.
Error: errors during apply: Error waiting for VPN Gateway "vgw-0d552249edec48941" to detach from VPC "vpc-0cbba5ddf6a4ec7ba": timeout while waiting for state to become 'detached' (last state: 'detaching', timeout: 15m0s)

--- FAIL: TestAccAwsDxGatewayAssociation_deprecatedSingleAccount (2551.41s)
testing.go:684: Step 0 error: errors during apply:
Error: error waiting for Direct Connect gateway association (ga-c1c37095-ab8d-4dcd-9f97-b369face1ad4vgw-0576f5ab3096ace51) to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 15m0s)
```

* service/directconnect: Remove vpn_gateway_id arguments

Reference: #13398

Changes:

```
* resource/aws_dx_gateway_association: Remove `vpn_gateway_id` argument
* resource/aws_dx_gateway_association_proposal: Remove `vpn_gateway_id` argument
```

Output from acceptance testing:

```
--- PASS: TestAccAwsDxGatewayAssociation_basicTransitGatewaySingleAccount (2063.56s)
--- PASS: TestAccAwsDxGatewayAssociation_basicTransitGatewayCrossAccount (2556.75s)
--- PASS: TestAccAwsDxGatewayAssociation_multiVpnGatewaysSingleAccount (2668.06s)
--- PASS: TestAccAwsDxGatewayAssociation_basicVpnGatewaySingleAccount (2674.09s)
--- PASS: TestAccAwsDxGatewayAssociation_basicVpnGatewayCrossAccount (2677.20s)
--- PASS: TestAccAwsDxGatewayAssociation_allowedPrefixesVpnGatewaySingleAccount (3612.36s)
--- PASS: TestAccAwsDxGatewayAssociation_allowedPrefixesVpnGatewayCrossAccount (3856.32s)

--- PASS: TestAccAwsDxGatewayAssociationProposal_basicVpnGateway (88.64s)
--- PASS: TestAccAwsDxGatewayAssociationProposal_disappears (96.50s)
--- PASS: TestAccAwsDxGatewayAssociationProposal_AllowedPrefixes (121.18s)
--- PASS: TestAccAwsDxGatewayAssociationProposal_basicTransitGateway (182.42s)
```

* tests/resource/aws_dx_gateway_association: Ensure v0 state upgrade is still covered by acceptance testing

Output from acceptance testing:

```
--- PASS: TestAccAwsDxGatewayAssociation_V0StateUpgrade (2605.48s)
```
  • Loading branch information
bflad authored Jul 24, 2020
1 parent 8d85033 commit ad65b1d
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 148 deletions.
49 changes: 12 additions & 37 deletions aws/resource_aws_dx_gateway_association.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package aws

import (
"errors"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -49,7 +48,7 @@ func resourceAwsDxGatewayAssociation() *schema.Resource {
Optional: true,
Computed: true,
ForceNew: true,
ConflictsWith: []string{"associated_gateway_owner_account_id", "proposal_id", "vpn_gateway_id"},
ConflictsWith: []string{"associated_gateway_owner_account_id", "proposal_id"},
},

"associated_gateway_owner_account_id": {
Expand All @@ -58,7 +57,7 @@ func resourceAwsDxGatewayAssociation() *schema.Resource {
Computed: true,
ForceNew: true,
ValidateFunc: validateAwsAccountId,
ConflictsWith: []string{"associated_gateway_id", "vpn_gateway_id"},
ConflictsWith: []string{"associated_gateway_id"},
},

"associated_gateway_type": {
Expand Down Expand Up @@ -86,22 +85,14 @@ func resourceAwsDxGatewayAssociation() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ConflictsWith: []string{"associated_gateway_id", "vpn_gateway_id"},
},

"vpn_gateway_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ConflictsWith: []string{"associated_gateway_id", "associated_gateway_owner_account_id", "proposal_id"},
Deprecated: "use 'associated_gateway_id' argument instead",
ConflictsWith: []string{"associated_gateway_id"},
},
},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(15 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(15 * time.Minute),
Create: schema.DefaultTimeout(30 * time.Minute),
Update: schema.DefaultTimeout(30 * time.Minute),
Delete: schema.DefaultTimeout(30 * time.Minute),
},
}
}
Expand All @@ -111,7 +102,6 @@ func resourceAwsDxGatewayAssociationCreate(d *schema.ResourceData, meta interfac

dxgwId := d.Get("dx_gateway_id").(string)
gwIdRaw, gwIdOk := d.GetOk("associated_gateway_id")
vgwIdRaw, vgwIdOk := d.GetOk("vpn_gateway_id")
gwAcctIdRaw, gwAcctIdOk := d.GetOk("associated_gateway_owner_account_id")
proposalIdRaw, proposalIdOk := d.GetOk("proposal_id")

Expand All @@ -120,8 +110,8 @@ func resourceAwsDxGatewayAssociationCreate(d *schema.ResourceData, meta interfac
if !(gwAcctIdOk && proposalIdOk) {
return fmt.Errorf("associated_gateway_owner_account_id and proposal_id must be configured")
}
} else if !(gwIdOk || vgwIdOk) {
return fmt.Errorf("either associated_gateway_owner_account_id and proposal_id or one of associated_gateway_id or vpn_gateway_id must be configured")
} else if !gwIdOk {
return fmt.Errorf("either associated_gateway_owner_account_id and proposal_id, or associated_gateway_id, must be configured")
}

associationId := ""
Expand All @@ -143,17 +133,12 @@ func resourceAwsDxGatewayAssociationCreate(d *schema.ResourceData, meta interfac
associationId = aws.StringValue(resp.DirectConnectGatewayAssociation.AssociationId)
d.SetId(dxGatewayAssociationId(dxgwId, aws.StringValue(resp.DirectConnectGatewayAssociation.AssociatedGateway.Id)))
} else {
gwId := gwIdRaw.(string)

req := &directconnect.CreateDirectConnectGatewayAssociationInput{
AddAllowedPrefixesToDirectConnectGateway: expandDxRouteFilterPrefixes(d.Get("allowed_prefixes").(*schema.Set)),
DirectConnectGatewayId: aws.String(dxgwId),
}
gwId := ""
if gwIdOk {
gwId = gwIdRaw.(string)
req.GatewayId = aws.String(gwId)
} else {
gwId = vgwIdRaw.(string)
req.VirtualGatewayId = aws.String(gwId)
GatewayId: aws.String(gwId),
}

log.Printf("[DEBUG] Creating Direct Connect gateway association: %#v", req)
Expand Down Expand Up @@ -196,11 +181,7 @@ func resourceAwsDxGatewayAssociationRead(d *schema.ResourceData, meta interface{
return fmt.Errorf("error setting allowed_prefixes: %s", err)
}

if _, ok := d.GetOk("vpn_gateway_id"); ok {
d.Set("vpn_gateway_id", assoc.VirtualGatewayId)
} else {
d.Set("associated_gateway_id", assoc.AssociatedGateway.Id)
}
d.Set("associated_gateway_id", assoc.AssociatedGateway.Id)
d.Set("associated_gateway_owner_account_id", assoc.AssociatedGateway.OwnerAccount)
d.Set("associated_gateway_type", assoc.AssociatedGateway.Type)
d.Set("dx_gateway_association_id", assoc.AssociationId)
Expand All @@ -213,12 +194,6 @@ func resourceAwsDxGatewayAssociationRead(d *schema.ResourceData, meta interface{
func resourceAwsDxGatewayAssociationUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).dxconn

_, gwIdOk := d.GetOk("associated_gateway_id")
_, vgwIdOk := d.GetOk("vpn_gateway_id")
if !gwIdOk && !vgwIdOk {
return errors.New("one of associated_gateway_id or vpn_gateway_id must be configured")
}

if d.HasChange("allowed_prefixes") {
associationId := d.Get("dx_gateway_association_id").(string)

Expand Down
1 change: 0 additions & 1 deletion aws/resource_aws_dx_gateway_association_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func resourceAwsDxGatewayAssociationResourceV0() *schema.Resource {
Optional: true,
ForceNew: true,
ConflictsWith: []string{"associated_gateway_id", "associated_gateway_owner_account_id", "proposal_id"},
Deprecated: "use 'associated_gateway_id' argument instead",
},
},
}
Expand Down
33 changes: 5 additions & 28 deletions aws/resource_aws_dx_gateway_association_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ func resourceAwsDxGatewayAssociationProposal() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
},
"associated_gateway_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ConflictsWith: []string{"vpn_gateway_id"},
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"associated_gateway_owner_account_id": {
Type: schema.TypeString,
Expand All @@ -67,13 +66,6 @@ func resourceAwsDxGatewayAssociationProposal() *schema.Resource {
ForceNew: true,
ValidateFunc: validateAwsAccountId,
},
"vpn_gateway_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ConflictsWith: []string{"associated_gateway_id"},
Deprecated: "use 'associated_gateway_id' argument instead",
},
},
}
}
Expand All @@ -86,20 +78,9 @@ func resourceAwsDxGatewayAssociationProposalCreate(d *schema.ResourceData, meta
AddAllowedPrefixesToDirectConnectGateway: allowedPrefixes,
DirectConnectGatewayId: aws.String(d.Get("dx_gateway_id").(string)),
DirectConnectGatewayOwnerAccount: aws.String(d.Get("dx_gateway_owner_account_id").(string)),
}
var gwID string
if v, ok := d.GetOk("vpn_gateway_id"); ok {
gwID = v.(string)
} else if v, ok := d.GetOk("associated_gateway_id"); ok {
gwID = v.(string)
GatewayId: aws.String(d.Get("associated_gateway_id").(string)),
}

if gwID == "" {
return fmt.Errorf("gateway id not provided, one of associated_gateway_id or vpn_gateway_id must be configured")
}

input.GatewayId = aws.String(gwID)

log.Printf("[DEBUG] Creating Direct Connect Gateway Association Proposal: %s", input)
output, err := conn.CreateDirectConnectGatewayAssociationProposal(input)

Expand Down Expand Up @@ -141,11 +122,7 @@ func resourceAwsDxGatewayAssociationProposalRead(d *schema.ResourceData, meta in
return fmt.Errorf("error setting allowed_prefixes: %s", err)
}

if _, ok := d.GetOk("vpn_gateway_id"); ok {
d.Set("vpn_gateway_id", aws.StringValue(proposal.AssociatedGateway.Id))
} else {
d.Set("associated_gateway_id", aws.StringValue(proposal.AssociatedGateway.Id))
}
d.Set("associated_gateway_id", aws.StringValue(proposal.AssociatedGateway.Id))
d.Set("associated_gateway_owner_account_id", proposal.AssociatedGateway.OwnerAccount)
d.Set("associated_gateway_type", proposal.AssociatedGateway.Type)
d.Set("dx_gateway_id", aws.StringValue(proposal.DirectConnectGatewayId))
Expand Down
45 changes: 0 additions & 45 deletions aws/resource_aws_dx_gateway_association_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,39 +78,6 @@ func testSweepDirectConnectGatewayAssociationProposals(region string) error {
return nil
}

func TestAccAwsDxGatewayAssociationProposal_VpnGatewayId(t *testing.T) {
var proposal1 directconnect.GatewayAssociationProposal
var providers []*schema.Provider
rBgpAsn := randIntRange(64512, 65534)
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_dx_gateway_association_proposal.test"
resourceNameDxGw := "aws_dx_gateway.test"
resourceNameVgw := "aws_vpn_gateway.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
testAccAlternateAccountPreCheck(t)
},
ProviderFactories: testAccProviderFactories(&providers),
CheckDestroy: testAccCheckAwsDxGatewayAssociationProposalDestroy,
Steps: []resource.TestStep{
{
Config: testAccDxGatewayAssociationProposalConfig_vpnGatewayId(rName, rBgpAsn),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsDxGatewayAssociationProposalExists(resourceName, &proposal1),
resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", resourceNameDxGw, "id"),
resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", resourceNameVgw, "id"),
resource.TestCheckNoResourceAttr(resourceName, "associated_gateway_id"),
testAccCheckResourceAttrAccountID(resourceName, "associated_gateway_owner_account_id"),
resource.TestCheckResourceAttr(resourceName, "associated_gateway_type", "virtualPrivateGateway"),
resource.TestCheckResourceAttr(resourceName, "allowed_prefixes.#", "1"),
),
},
},
})
}

func TestAccAwsDxGatewayAssociationProposal_basicVpnGateway(t *testing.T) {
var proposal1 directconnect.GatewayAssociationProposal
var providers []*schema.Provider
Expand All @@ -134,7 +101,6 @@ func TestAccAwsDxGatewayAssociationProposal_basicVpnGateway(t *testing.T) {
testAccCheckAwsDxGatewayAssociationProposalExists(resourceName, &proposal1),
resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", resourceNameDxGw, "id"),
resource.TestCheckResourceAttrPair(resourceName, "associated_gateway_id", resourceNameVgw, "id"),
resource.TestCheckNoResourceAttr(resourceName, "vpn_gateway_id"),
testAccCheckResourceAttrAccountID(resourceName, "associated_gateway_owner_account_id"),
resource.TestCheckResourceAttr(resourceName, "associated_gateway_type", "virtualPrivateGateway"),
resource.TestCheckResourceAttr(resourceName, "allowed_prefixes.#", "1"),
Expand Down Expand Up @@ -173,7 +139,6 @@ func TestAccAwsDxGatewayAssociationProposal_basicTransitGateway(t *testing.T) {
testAccCheckAwsDxGatewayAssociationProposalExists(resourceName, &proposal1),
resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", resourceNameDxGw, "id"),
resource.TestCheckResourceAttrPair(resourceName, "associated_gateway_id", resourceNameTgw, "id"),
resource.TestCheckNoResourceAttr(resourceName, "vpn_gateway_id"),
testAccCheckResourceAttrAccountID(resourceName, "associated_gateway_owner_account_id"),
resource.TestCheckResourceAttr(resourceName, "associated_gateway_type", "transitGateway"),
resource.TestCheckResourceAttr(resourceName, "allowed_prefixes.#", "2"),
Expand Down Expand Up @@ -358,16 +323,6 @@ resource "aws_vpn_gateway" "test" {
`, rName, rBgpAsn)
}

func testAccDxGatewayAssociationProposalConfig_vpnGatewayId(rName string, rBgpAsn int) string {
return testAccDxGatewayAssociationProposalConfigBase_vpnGateway(rName, rBgpAsn) + `
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}"
vpn_gateway_id = "${aws_vpn_gateway.test.id}"
}
`
}

func testAccDxGatewayAssociationProposalConfig_basicVpnGateway(rName string, rBgpAsn int) string {
return testAccDxGatewayAssociationProposalConfigBase_vpnGateway(rName, rBgpAsn) + `
resource "aws_dx_gateway_association_proposal" "test" {
Expand Down
31 changes: 4 additions & 27 deletions aws/resource_aws_dx_gateway_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,9 @@ func testSweepDirectConnectGatewayAssociations(region string) error {
return nil
}

func TestAccAwsDxGatewayAssociation_deprecatedSingleAccount(t *testing.T) {
// V0 state upgrade testing must be done via acceptance testing due to API call
func TestAccAwsDxGatewayAssociation_V0StateUpgrade(t *testing.T) {
resourceName := "aws_dx_gateway_association.test"
resourceNameDxGw := "aws_dx_gateway.test"
resourceNameVgw := "aws_vpn_gateway.test"
rName := fmt.Sprintf("terraform-testacc-dxgwassoc-%d", acctest.RandInt())
rBgpAsn := randIntRange(64512, 65534)

Expand All @@ -195,18 +194,9 @@ func TestAccAwsDxGatewayAssociation_deprecatedSingleAccount(t *testing.T) {
CheckDestroy: testAccCheckAwsDxGatewayAssociationDestroy,
Steps: []resource.TestStep{
{
Config: testAccDxGatewayAssociationConfig_deprecatedSingleAccount(rName, rBgpAsn),
Config: testAccDxGatewayAssociationConfig_basicVpnGatewaySingleAccount(rName, rBgpAsn),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsDxGatewayAssociationExists(resourceName),
resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", resourceNameDxGw, "id"),
resource.TestCheckResourceAttrPair(resourceName, "vpn_gateway_id", resourceNameVgw, "id"),
resource.TestCheckResourceAttrSet(resourceName, "dx_gateway_association_id"),
resource.TestCheckNoResourceAttr(resourceName, "associated_gateway_id"),
resource.TestCheckResourceAttr(resourceName, "associated_gateway_type", "virtualPrivateGateway"),
testAccCheckResourceAttrAccountID(resourceName, "associated_gateway_owner_account_id"),
testAccCheckResourceAttrAccountID(resourceName, "dx_gateway_owner_account_id"),
resource.TestCheckResourceAttr(resourceName, "allowed_prefixes.#", "1"),
tfawsresource.TestCheckTypeSetElemAttr(resourceName, "allowed_prefixes.*", "10.255.255.0/28"),
testAccCheckAwsDxGatewayAssociationStateUpgradeV0(resourceName),
),
},
Expand All @@ -233,7 +223,6 @@ func TestAccAwsDxGatewayAssociation_basicVpnGatewaySingleAccount(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", resourceNameDxGw, "id"),
resource.TestCheckResourceAttrPair(resourceName, "associated_gateway_id", resourceNameVgw, "id"),
resource.TestCheckResourceAttrSet(resourceName, "dx_gateway_association_id"),
resource.TestCheckNoResourceAttr(resourceName, "vpn_gateway_id"),
resource.TestCheckResourceAttr(resourceName, "associated_gateway_type", "virtualPrivateGateway"),
testAccCheckResourceAttrAccountID(resourceName, "associated_gateway_owner_account_id"),
testAccCheckResourceAttrAccountID(resourceName, "dx_gateway_owner_account_id"),
Expand Down Expand Up @@ -281,7 +270,6 @@ func TestAccAwsDxGatewayAssociation_basicVpnGatewayCrossAccount(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", resourceNameDxGw, "id"),
resource.TestCheckResourceAttrPair(resourceName, "associated_gateway_id", resourceNameVgw, "id"),
resource.TestCheckResourceAttrSet(resourceName, "dx_gateway_association_id"),
resource.TestCheckNoResourceAttr(resourceName, "vpn_gateway_id"),
resource.TestCheckResourceAttr(resourceName, "associated_gateway_type", "virtualPrivateGateway"),
testAccCheckResourceAttrAccountID(resourceName, "associated_gateway_owner_account_id"),
// dx_gateway_owner_account_id is the "aws.alternate" provider's account ID.
Expand Down Expand Up @@ -313,7 +301,6 @@ func TestAccAwsDxGatewayAssociation_basicTransitGatewaySingleAccount(t *testing.
resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", resourceNameDxGw, "id"),
resource.TestCheckResourceAttrPair(resourceName, "associated_gateway_id", resourceNameTgw, "id"),
resource.TestCheckResourceAttrSet(resourceName, "dx_gateway_association_id"),
resource.TestCheckNoResourceAttr(resourceName, "vpn_gateway_id"),
resource.TestCheckResourceAttr(resourceName, "associated_gateway_type", "transitGateway"),
testAccCheckResourceAttrAccountID(resourceName, "associated_gateway_owner_account_id"),
testAccCheckResourceAttrAccountID(resourceName, "dx_gateway_owner_account_id"),
Expand Down Expand Up @@ -362,7 +349,6 @@ func TestAccAwsDxGatewayAssociation_basicTransitGatewayCrossAccount(t *testing.T
resource.TestCheckResourceAttrPair(resourceName, "dx_gateway_id", resourceNameDxGw, "id"),
resource.TestCheckResourceAttrPair(resourceName, "associated_gateway_id", resourceNameTgw, "id"),
resource.TestCheckResourceAttrSet(resourceName, "dx_gateway_association_id"),
resource.TestCheckNoResourceAttr(resourceName, "vpn_gateway_id"),
resource.TestCheckResourceAttr(resourceName, "associated_gateway_type", "transitGateway"),
testAccCheckResourceAttrAccountID(resourceName, "associated_gateway_owner_account_id"),
// dx_gateway_owner_account_id is the "aws.alternate" provider's account ID.
Expand Down Expand Up @@ -537,7 +523,7 @@ func testAccCheckAwsDxGatewayAssociationStateUpgradeV0(name string) resource.Tes

rawState := map[string]interface{}{
"dx_gateway_id": rs.Primary.Attributes["dx_gateway_id"],
"vpn_gateway_id": rs.Primary.Attributes["vpn_gateway_id"],
"vpn_gateway_id": rs.Primary.Attributes["associated_gateway_id"], // vpn_gateway_id was removed in 3.0, but older state still has it
}

updatedRawState, err := resourceAwsDxGatewayAssociationStateUpgradeV0(rawState, testAccProvider.Meta())
Expand Down Expand Up @@ -615,15 +601,6 @@ resource "aws_dx_gateway" "test" {
`, rName, rBgpAsn)
}

func testAccDxGatewayAssociationConfig_deprecatedSingleAccount(rName string, rBgpAsn int) string {
return testAccDxGatewayAssociationConfigBase_vpnGatewaySingleAccount(rName, rBgpAsn) + `
resource "aws_dx_gateway_association" "test" {
dx_gateway_id = "${aws_dx_gateway.test.id}"
vpn_gateway_id = "${aws_vpn_gateway_attachment.test.vpn_gateway_id}"
}
`
}

func testAccDxGatewayAssociationConfig_basicVpnGatewaySingleAccount(rName string, rBgpAsn int) string {
return testAccDxGatewayAssociationConfigBase_vpnGatewaySingleAccount(rName, rBgpAsn) + `
resource "aws_dx_gateway_association" "test" {
Expand Down
Loading

0 comments on commit ad65b1d

Please sign in to comment.