Merge pull request #1352 from hashicorp/b-rds-pointers
providers/aws: pass pointers directly to d.Set in RDS
This commit is contained in:
commit
cedfadc808
|
@ -318,33 +318,38 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if v.DBName != nil {
|
||||
d.Set("name", *v.DBName)
|
||||
} else {
|
||||
d.Set("name", "")
|
||||
d.Set("name", v.DBName)
|
||||
d.Set("username", v.MasterUsername)
|
||||
d.Set("engine", v.Engine)
|
||||
d.Set("engine_version", v.EngineVersion)
|
||||
d.Set("allocated_storage", v.AllocatedStorage)
|
||||
d.Set("storage_type", v.StorageType)
|
||||
d.Set("instance_class", v.DBInstanceClass)
|
||||
d.Set("availability_zone", v.AvailabilityZone)
|
||||
d.Set("backup_retention_period", v.BackupRetentionPeriod)
|
||||
d.Set("backup_window", v.PreferredBackupWindow)
|
||||
d.Set("maintenance_window", v.PreferredMaintenanceWindow)
|
||||
d.Set("multi_az", v.MultiAZ)
|
||||
if v.DBSubnetGroup != nil {
|
||||
d.Set("db_subnet_group_name", v.DBSubnetGroup.DBSubnetGroupName)
|
||||
}
|
||||
d.Set("username", *v.MasterUsername)
|
||||
d.Set("engine", *v.Engine)
|
||||
d.Set("engine_version", *v.EngineVersion)
|
||||
d.Set("allocated_storage", *v.AllocatedStorage)
|
||||
d.Set("storage_type", *v.StorageType)
|
||||
d.Set("instance_class", *v.DBInstanceClass)
|
||||
d.Set("availability_zone", *v.AvailabilityZone)
|
||||
d.Set("backup_retention_period", *v.BackupRetentionPeriod)
|
||||
d.Set("backup_window", *v.PreferredBackupWindow)
|
||||
d.Set("maintenance_window", *v.PreferredMaintenanceWindow)
|
||||
d.Set("multi_az", *v.MultiAZ)
|
||||
d.Set("port", *v.Endpoint.Port)
|
||||
d.Set("db_subnet_group_name", *v.DBSubnetGroup.DBSubnetGroupName)
|
||||
|
||||
if len(v.DBParameterGroups) > 0 {
|
||||
d.Set("parameter_group_name", *v.DBParameterGroups[0].DBParameterGroupName)
|
||||
d.Set("parameter_group_name", v.DBParameterGroups[0].DBParameterGroupName)
|
||||
}
|
||||
|
||||
d.Set("address", *v.Endpoint.Address)
|
||||
d.Set("endpoint", fmt.Sprintf("%s:%d", *v.Endpoint.Address, *v.Endpoint.Port))
|
||||
d.Set("status", *v.DBInstanceStatus)
|
||||
d.Set("storage_encrypted", *v.StorageEncrypted)
|
||||
if v.Endpoint != nil {
|
||||
d.Set("port", v.Endpoint.Port)
|
||||
d.Set("address", v.Endpoint.Address)
|
||||
|
||||
if v.Endpoint.Address != nil && v.Endpoint.Port != nil {
|
||||
d.Set("endpoint",
|
||||
fmt.Sprintf("%s:%d", *v.Endpoint.Address, *v.Endpoint.Port))
|
||||
}
|
||||
}
|
||||
|
||||
d.Set("status", v.DBInstanceStatus)
|
||||
d.Set("storage_encrypted", v.StorageEncrypted)
|
||||
|
||||
// list tags for resource
|
||||
// set tags
|
||||
|
|
|
@ -2,7 +2,9 @@ package aws
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
@ -24,8 +26,6 @@ func TestAccAWSDBInstance(t *testing.T) {
|
|||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v),
|
||||
testAccCheckAWSDBInstanceAttributes(&v),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_db_instance.bar", "identifier", "foobarbaz-test-terraform"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_db_instance.bar", "allocated_storage", "10"),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -133,9 +133,12 @@ func testAccCheckAWSDBInstanceExists(n string, v *rds.DBInstance) resource.TestC
|
|||
}
|
||||
}
|
||||
|
||||
const testAccAWSDBInstanceConfig = `
|
||||
// Database names cannot collide, and deletion takes so long, that making the
|
||||
// name a bit random helps so able we can kill a test that's just waiting for a
|
||||
// delete and not be blocked on kicking off another one.
|
||||
var testAccAWSDBInstanceConfig = fmt.Sprintf(`
|
||||
resource "aws_db_instance" "bar" {
|
||||
identifier = "foobarbaz-test-terraform"
|
||||
identifier = "foobarbaz-test-terraform-%d"
|
||||
|
||||
allocated_storage = 10
|
||||
engine = "mysql"
|
||||
|
@ -148,5 +151,4 @@ resource "aws_db_instance" "bar" {
|
|||
backup_retention_period = 0
|
||||
|
||||
parameter_group_name = "default.mysql5.6"
|
||||
}
|
||||
`
|
||||
}`, rand.New(rand.NewSource(time.Now().UnixNano())).Int())
|
||||
|
|
Loading…
Reference in New Issue