Merge pull request #3053 from hashicorp/b-aws-db-updates
provider/aws: Updates for RDS
This commit is contained in:
commit
64258c1efd
|
@ -139,6 +139,13 @@ func resourceAwsDbInstance() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
StateFunc: func(v interface{}) string {
|
||||
if v != nil {
|
||||
value := v.(string)
|
||||
return strings.ToLower(value)
|
||||
}
|
||||
return ""
|
||||
},
|
||||
},
|
||||
|
||||
"multi_az": &schema.Schema{
|
||||
|
@ -255,6 +262,12 @@ func resourceAwsDbInstance() *schema.Resource {
|
|||
Optional: true,
|
||||
},
|
||||
|
||||
"allow_major_version_upgrade": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Computed: false,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"tags": tagsSchema(),
|
||||
},
|
||||
}
|
||||
|
@ -616,6 +629,11 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
req.AllocatedStorage = aws.Int64(int64(d.Get("allocated_storage").(int)))
|
||||
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") {
|
||||
d.SetPartial("backup_retention_period")
|
||||
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)
|
||||
|
||||
return resourceAwsDbInstanceRead(d, meta)
|
||||
}
|
||||
|
||||
|
@ -742,7 +761,6 @@ func resourceAwsDbInstanceRetrieve(
|
|||
log.Printf("[DEBUG] DB Instance describe configuration: %#v", opts)
|
||||
|
||||
resp, err := conn.DescribeDBInstances(&opts)
|
||||
|
||||
if err != nil {
|
||||
dbinstanceerr, ok := err.(awserr.Error)
|
||||
if ok && dbinstanceerr.Code() == "DBInstanceNotFound" {
|
||||
|
|
|
@ -183,6 +183,12 @@ resource "aws_db_instance" "bar" {
|
|||
password = "barbarbarbar"
|
||||
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
|
||||
|
||||
parameter_group_name = "default.mysql5.6"
|
||||
|
|
|
@ -18,6 +18,7 @@ func resourceAwsDbSubnetGroup() *schema.Resource {
|
|||
return &schema.Resource{
|
||||
Create: resourceAwsDbSubnetGroupCreate,
|
||||
Read: resourceAwsDbSubnetGroupRead,
|
||||
Update: resourceAwsDbSubnetGroupUpdate,
|
||||
Delete: resourceAwsDbSubnetGroupDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
@ -52,7 +53,6 @@ func resourceAwsDbSubnetGroup() *schema.Resource {
|
|||
"subnet_ids": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
@ -133,6 +133,32 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro
|
|||
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 {
|
||||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"pending"},
|
||||
|
|
Loading…
Reference in New Issue