From 83fe23ea9c9ca9709df8c68919e3592c92226f5d Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 13 Jul 2020 14:30:04 -0400 Subject: [PATCH] resource/aws_dx_gateway: Remove automatic aws_dx_gateway_association import (#14124) Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/13408 Output from acceptance testing: ``` --- PASS: TestAccAwsDxGateway_basic (54.91s) --- PASS: TestAccAwsDxGateway_complex (2018.49s) ``` --- aws/resource_aws_dx_gateway.go | 24 +------------------ aws/resource_aws_dx_gateway_test.go | 8 ------- website/docs/guides/version-3-upgrade.html.md | 7 ++++++ 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/aws/resource_aws_dx_gateway.go b/aws/resource_aws_dx_gateway.go index 1fa399070296..563467c800df 100644 --- a/aws/resource_aws_dx_gateway.go +++ b/aws/resource_aws_dx_gateway.go @@ -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{ @@ -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{ diff --git a/aws/resource_aws_dx_gateway_test.go b/aws/resource_aws_dx_gateway_test.go index 4ad53bb19f8c..68f3b39c6974 100644 --- a/aws/resource_aws_dx_gateway_test.go +++ b/aws/resource_aws_dx_gateway_test.go @@ -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) @@ -167,7 +160,6 @@ func TestAccAwsDxGateway_complex(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateCheck: checkFn, ImportStateVerify: true, }, }, diff --git a/website/docs/guides/version-3-upgrade.html.md b/website/docs/guides/version-3-upgrade.html.md index 5d65c9dc9588..ed6aab5705ea 100644 --- a/website/docs/guides/version-3-upgrade.html.md +++ b/website/docs/guides/version-3-upgrade.html.md @@ -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) @@ -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