From 0a2245cbaee80d96968ce55f4ecc5ccbc2db0f8f Mon Sep 17 00:00:00 2001 From: stack72 Date: Sun, 26 Jun 2016 21:20:52 +0100 Subject: [PATCH] provider/aws: Support Import for `aws_db_parameter_group` ``` make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSDBParameterGroup_' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /vendor/) TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSDBParameterGroup_ -timeout 120m === RUN TestAccAWSDBParameterGroup_importBasic --- PASS: TestAccAWSDBParameterGroup_importBasic (31.03s) === RUN TestAccAWSDBParameterGroup_basic --- PASS: TestAccAWSDBParameterGroup_basic (51.22s) === RUN TestAccAWSDBParameterGroup_Only --- PASS: TestAccAWSDBParameterGroup_Only (25.45s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 107.725s ``` --- ...mport_aws_db_parameter_group_group_test.go | 31 +++++++++++++++++++ .../aws/resource_aws_db_parameter_group.go | 4 +++ 2 files changed, 35 insertions(+) create mode 100644 builtin/providers/aws/import_aws_db_parameter_group_group_test.go diff --git a/builtin/providers/aws/import_aws_db_parameter_group_group_test.go b/builtin/providers/aws/import_aws_db_parameter_group_group_test.go new file mode 100644 index 000000000..d9806e5cf --- /dev/null +++ b/builtin/providers/aws/import_aws_db_parameter_group_group_test.go @@ -0,0 +1,31 @@ +package aws + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSDBParameterGroup_importBasic(t *testing.T) { + resourceName := "aws_db_parameter_group.bar" + groupName := fmt.Sprintf("parameter-group-test-terraform-%d", acctest.RandInt()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSDBParameterGroupDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSDBParameterGroupConfig(groupName), + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/builtin/providers/aws/resource_aws_db_parameter_group.go b/builtin/providers/aws/resource_aws_db_parameter_group.go index 2dcbc7fca..5f450a292 100644 --- a/builtin/providers/aws/resource_aws_db_parameter_group.go +++ b/builtin/providers/aws/resource_aws_db_parameter_group.go @@ -23,6 +23,10 @@ func resourceAwsDbParameterGroup() *schema.Resource { Read: resourceAwsDbParameterGroupRead, Update: resourceAwsDbParameterGroupUpdate, Delete: resourceAwsDbParameterGroupDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ "arn": &schema.Schema{ Type: schema.TypeString,