From 96ef187914235a931e73043838e16951af6fa902 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sun, 14 Jan 2018 17:58:57 -0500 Subject: [PATCH] terraform import aws_dx_lag and aws_dx_connection. --- aws/import_aws_dx_connection_test.go | 29 +++++++++++++++++++++ aws/import_aws_dx_lag_test.go | 30 ++++++++++++++++++++++ aws/resource_aws_dx_connection.go | 3 +++ aws/resource_aws_dx_lag.go | 3 +++ website/docs/r/dx_connection.html.markdown | 8 ++++++ website/docs/r/dx_lag.html.markdown | 8 ++++++ 6 files changed, 81 insertions(+) create mode 100644 aws/import_aws_dx_connection_test.go create mode 100644 aws/import_aws_dx_lag_test.go diff --git a/aws/import_aws_dx_connection_test.go b/aws/import_aws_dx_connection_test.go new file mode 100644 index 000000000000..022da657198e --- /dev/null +++ b/aws/import_aws_dx_connection_test.go @@ -0,0 +1,29 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAwsDxConnection_importBasic(t *testing.T) { + resourceName := "aws_dx_connection.hoge" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAwsDxConnectionDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccDxConnectionConfig(acctest.RandString(5)), + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/aws/import_aws_dx_lag_test.go b/aws/import_aws_dx_lag_test.go new file mode 100644 index 000000000000..3417437f9ebf --- /dev/null +++ b/aws/import_aws_dx_lag_test.go @@ -0,0 +1,30 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAwsDxLag_importBasic(t *testing.T) { + resourceName := "aws_dx_lag.hoge" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAwsDxLagDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccDxLagConfig(acctest.RandString(5)), + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"force_destroy"}, + }, + }, + }) +} diff --git a/aws/resource_aws_dx_connection.go b/aws/resource_aws_dx_connection.go index fa3a955e3fe3..0dc1066256b7 100644 --- a/aws/resource_aws_dx_connection.go +++ b/aws/resource_aws_dx_connection.go @@ -18,6 +18,9 @@ func resourceAwsDxConnection() *schema.Resource { Read: resourceAwsDxConnectionRead, Update: resourceAwsDxConnectionUpdate, Delete: resourceAwsDxConnectionDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "arn": { diff --git a/aws/resource_aws_dx_lag.go b/aws/resource_aws_dx_lag.go index 7aba34104052..7b426d4b37ea 100644 --- a/aws/resource_aws_dx_lag.go +++ b/aws/resource_aws_dx_lag.go @@ -18,6 +18,9 @@ func resourceAwsDxLag() *schema.Resource { Read: resourceAwsDxLagRead, Update: resourceAwsDxLagUpdate, Delete: resourceAwsDxLagDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "arn": { diff --git a/website/docs/r/dx_connection.html.markdown b/website/docs/r/dx_connection.html.markdown index 49c47cee5a44..1e7bacbfd90f 100644 --- a/website/docs/r/dx_connection.html.markdown +++ b/website/docs/r/dx_connection.html.markdown @@ -35,3 +35,11 @@ The following attributes are exported: * `id` - The ID of the connection. * `arn` - The ARN of the connection. + +## Import + +Direct Connect connections can be imported using the `connection id`, e.g. + +``` +$ terraform import aws_dx_connection.test_connection dxcon-ffre0ec3 +``` diff --git a/website/docs/r/dx_lag.html.markdown b/website/docs/r/dx_lag.html.markdown index 27c91d745c52..d1c8c2672e25 100644 --- a/website/docs/r/dx_lag.html.markdown +++ b/website/docs/r/dx_lag.html.markdown @@ -39,3 +39,11 @@ The following attributes are exported: * `id` - The ID of the LAG. * `arn` - The ARN of the LAG. + +## Import + +Direct Connect LAGs can be imported using the `lag id`, e.g. + +``` +$ terraform import aws_dx_lag.test_lag dxlag-fgnsp5rq +```