Skip to content

Commit

Permalink
resource/aws_dx_gateway: Remove automatic aws_dx_gateway_association …
Browse files Browse the repository at this point in the history
…import (#14124)

Reference: #13408

Output from acceptance testing:

```
--- PASS: TestAccAwsDxGateway_basic (54.91s)
--- PASS: TestAccAwsDxGateway_complex (2018.49s)
```
  • Loading branch information
bflad authored Jul 13, 2020
1 parent e75aa1c commit 83fe23e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
24 changes: 1 addition & 23 deletions aws/resource_aws_dx_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func resourceAwsDxGateway() *schema.Resource {
Read: resourceAwsDxGatewayRead,
Delete: resourceAwsDxGatewayDelete,
Importer: &schema.ResourceImporter{
State: resourceAwsDxGatewayImportState,
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -125,28 +125,6 @@ func resourceAwsDxGatewayDelete(d *schema.ResourceData, meta interface{}) error
return nil
}

func resourceAwsDxGatewayImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
conn := meta.(*AWSClient).dxconn

resp, err := conn.DescribeDirectConnectGatewayAssociations(&directconnect.DescribeDirectConnectGatewayAssociationsInput{
DirectConnectGatewayId: aws.String(d.Id()),
})
if err != nil {
return nil, fmt.Errorf("error reading Direct Connect gateway association: %s", err)
}

results := []*schema.ResourceData{d}
for _, assoc := range resp.DirectConnectGatewayAssociations {
d := resourceAwsDxGatewayAssociation().Data(nil)
d.SetType("aws_dx_gateway_association")
d.SetId(dxGatewayAssociationId(aws.StringValue(assoc.DirectConnectGatewayId), aws.StringValue(assoc.AssociatedGateway.Id)))
d.Set("dx_gateway_association_id", assoc.AssociationId)
results = append(results, d)
}

return results, nil
}

func dxGatewayStateRefresh(conn *directconnect.DirectConnect, dxgwId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
resp, err := conn.DescribeDirectConnectGateways(&directconnect.DescribeDirectConnectGatewaysInput{
Expand Down
8 changes: 0 additions & 8 deletions aws/resource_aws_dx_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ func TestAccAwsDxGateway_basic(t *testing.T) {
}

func TestAccAwsDxGateway_complex(t *testing.T) {
checkFn := func(s []*terraform.InstanceState) error {
if len(s) != 3 {
return fmt.Errorf("Got %d resources, expected 3. State: %#v", len(s), s)
}
return nil
}

rName1 := fmt.Sprintf("terraform-testacc-dxgwassoc-%d", acctest.RandInt())
rName2 := fmt.Sprintf("terraform-testacc-dxgwassoc-%d", acctest.RandInt())
rBgpAsn := randIntRange(64512, 65534)
Expand All @@ -167,7 +160,6 @@ func TestAccAwsDxGateway_complex(t *testing.T) {
{
ResourceName: resourceName,
ImportState: true,
ImportStateCheck: checkFn,
ImportStateVerify: true,
},
},
Expand Down
7 changes: 7 additions & 0 deletions website/docs/guides/version-3-upgrade.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Upgrade topics:
- [Provider Authentication Updates](#provider-authentication-updates)
- [Data Source: aws_availability_zones](#data-source-aws_availability_zones)
- [Data Source: aws_lambda_invocation](#data-source-aws_lambda_invocation)
- [Resource: aws_dx_gateway](#resource-aws_dx_gateway)
- [Resource: aws_emr_cluster](#resource-aws_emr_cluster)
- [Resource: aws_lb_listener_rule](#resource-aws_lb_listener_rule)
- [Resource: aws_s3_bucket](#resource-aws_s3_bucket)
Expand Down Expand Up @@ -149,6 +150,12 @@ output "lambda_result" {
}
```

## Resource: aws_dx_gateway

### Removal of Automatic aws_dx_gateway_association Import

Previously when importing the `aws_dx_gateway` resource with the [`terraform import` command](/docs/commands/import.html), the Terraform AWS Provider would automatically attempt to import an associated `aws_dx_gateway_association` resource(s) as well. This automatic resource import has been removed. Use the [`aws_dx_gateway_association` resource import](/docs/providers/aws/r/dx_gateway_association.html#import) to import those resources separately.

## Resource: aws_emr_cluster

### core_instance_count Argument Removal
Expand Down

0 comments on commit 83fe23e

Please sign in to comment.