From ea4483d8b608e44e88a6225c92bd7c6f10814ede Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Mon, 11 Jul 2016 21:59:14 +0100 Subject: [PATCH] provider/aws: Support Import `aws_rds_cluster_instance` (#7522) We were not setting all the values in the read Func. One other issue, we were setting the *wrong* db_parameter_name value to state ``` make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSRDSClusterInstance_import' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /vendor/) TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSRDSClusterInstance_import -timeout 120m === RUN TestAccAWSRDSClusterInstance_importBasic --- PASS: TestAccAWSRDSClusterInstance_importBasic (1201.80s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 1201.814s ``` --- .../import_aws_rds_cluster_instance_test.go | 29 +++++++++++++++++++ .../aws/resource_aws_rds_cluster_instance.go | 8 ++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 builtin/providers/aws/import_aws_rds_cluster_instance_test.go diff --git a/builtin/providers/aws/import_aws_rds_cluster_instance_test.go b/builtin/providers/aws/import_aws_rds_cluster_instance_test.go new file mode 100644 index 000000000..949acead7 --- /dev/null +++ b/builtin/providers/aws/import_aws_rds_cluster_instance_test.go @@ -0,0 +1,29 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSRDSClusterInstance_importBasic(t *testing.T) { + resourceName := "aws_rds_cluster_instance.cluster_instances" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSClusterDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSClusterInstanceConfig(acctest.RandInt()), + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/builtin/providers/aws/resource_aws_rds_cluster_instance.go b/builtin/providers/aws/resource_aws_rds_cluster_instance.go index 09580cc89..5289e4782 100644 --- a/builtin/providers/aws/resource_aws_rds_cluster_instance.go +++ b/builtin/providers/aws/resource_aws_rds_cluster_instance.go @@ -17,6 +17,9 @@ func resourceAwsRDSClusterInstance() *schema.Resource { Read: resourceAwsRDSClusterInstanceRead, Update: resourceAwsRDSClusterInstanceUpdate, Delete: resourceAwsRDSClusterInstanceDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "identifier": &schema.Schema{ @@ -185,9 +188,12 @@ func resourceAwsRDSClusterInstanceRead(d *schema.ResourceData, meta interface{}) } d.Set("publicly_accessible", db.PubliclyAccessible) + d.Set("cluster_identifier", db.DBClusterIdentifier) + d.Set("instance_class", db.DBInstanceClass) + d.Set("identifier", db.DBInstanceIdentifier) if len(db.DBParameterGroups) > 0 { - d.Set("parameter_group_name", db.DBParameterGroups[0].DBParameterGroupName) + d.Set("db_parameter_group_name", db.DBParameterGroups[0].DBParameterGroupName) } // Fetch and save tags