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
```
This commit is contained in:
Paul Stack 2016-07-11 21:59:14 +01:00 committed by Clint
parent 38e3d3ba87
commit ea4483d8b6
2 changed files with 36 additions and 1 deletions

View File

@ -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,
},
},
})
}

View File

@ -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