Merge pull request #3053 from hashicorp/b-aws-db-updates

provider/aws: Updates for RDS
This commit is contained in:
Clint 2015-08-28 10:26:11 -05:00
commit 64258c1efd
3 changed files with 52 additions and 2 deletions

View File

@ -139,6 +139,13 @@ func resourceAwsDbInstance() *schema.Resource {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
Computed: true, Computed: true,
StateFunc: func(v interface{}) string {
if v != nil {
value := v.(string)
return strings.ToLower(value)
}
return ""
},
}, },
"multi_az": &schema.Schema{ "multi_az": &schema.Schema{
@ -255,6 +262,12 @@ func resourceAwsDbInstance() *schema.Resource {
Optional: true, Optional: true,
}, },
"allow_major_version_upgrade": &schema.Schema{
Type: schema.TypeBool,
Computed: false,
Optional: true,
},
"tags": tagsSchema(), "tags": tagsSchema(),
}, },
} }
@ -616,6 +629,11 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
req.AllocatedStorage = aws.Int64(int64(d.Get("allocated_storage").(int))) req.AllocatedStorage = aws.Int64(int64(d.Get("allocated_storage").(int)))
requestUpdate = true requestUpdate = true
} }
if d.HasChange("allow_major_version_upgrade") {
d.SetPartial("allow_major_version_upgrade")
req.AllowMajorVersionUpgrade = aws.Bool(d.Get("allow_major_version_upgrade").(bool))
requestUpdate = true
}
if d.HasChange("backup_retention_period") { if d.HasChange("backup_retention_period") {
d.SetPartial("backup_retention_period") d.SetPartial("backup_retention_period")
req.BackupRetentionPeriod = aws.Int64(int64(d.Get("backup_retention_period").(int))) req.BackupRetentionPeriod = aws.Int64(int64(d.Get("backup_retention_period").(int)))
@ -728,6 +746,7 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
} }
} }
d.Partial(false) d.Partial(false)
return resourceAwsDbInstanceRead(d, meta) return resourceAwsDbInstanceRead(d, meta)
} }
@ -742,7 +761,6 @@ func resourceAwsDbInstanceRetrieve(
log.Printf("[DEBUG] DB Instance describe configuration: %#v", opts) log.Printf("[DEBUG] DB Instance describe configuration: %#v", opts)
resp, err := conn.DescribeDBInstances(&opts) resp, err := conn.DescribeDBInstances(&opts)
if err != nil { if err != nil {
dbinstanceerr, ok := err.(awserr.Error) dbinstanceerr, ok := err.(awserr.Error)
if ok && dbinstanceerr.Code() == "DBInstanceNotFound" { if ok && dbinstanceerr.Code() == "DBInstanceNotFound" {

View File

@ -183,6 +183,12 @@ resource "aws_db_instance" "bar" {
password = "barbarbarbar" password = "barbarbarbar"
username = "foo" username = "foo"
# Maintenance Window is stored in lower case in the API, though not strictly
# documented. Terraform will downcase this to match (as opposed to throw a
# validation error).
maintenance_window = "Fri:09:00-Fri:09:30"
backup_retention_period = 0 backup_retention_period = 0
parameter_group_name = "default.mysql5.6" parameter_group_name = "default.mysql5.6"

View File

@ -18,6 +18,7 @@ func resourceAwsDbSubnetGroup() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
Create: resourceAwsDbSubnetGroupCreate, Create: resourceAwsDbSubnetGroupCreate,
Read: resourceAwsDbSubnetGroupRead, Read: resourceAwsDbSubnetGroupRead,
Update: resourceAwsDbSubnetGroupUpdate,
Delete: resourceAwsDbSubnetGroupDelete, Delete: resourceAwsDbSubnetGroupDelete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
@ -52,7 +53,6 @@ func resourceAwsDbSubnetGroup() *schema.Resource {
"subnet_ids": &schema.Schema{ "subnet_ids": &schema.Schema{
Type: schema.TypeSet, Type: schema.TypeSet,
Required: true, Required: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString, Set: schema.HashString,
}, },
@ -133,6 +133,32 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro
return nil return nil
} }
func resourceAwsDbSubnetGroupUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsconn
if d.HasChange("subnet_ids") {
_, n := d.GetChange("subnet_ids")
if n == nil {
n = new(schema.Set)
}
ns := n.(*schema.Set)
var sIds []*string
for _, s := range ns.List() {
sIds = append(sIds, aws.String(s.(string)))
}
_, err := conn.ModifyDBSubnetGroup(&rds.ModifyDBSubnetGroupInput{
DBSubnetGroupName: aws.String(d.Id()),
SubnetIds: sIds,
})
if err != nil {
return err
}
}
return resourceAwsDbSubnetGroupRead(d, meta)
}
func resourceAwsDbSubnetGroupDelete(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbSubnetGroupDelete(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Pending: []string{"pending"}, Pending: []string{"pending"},