Merge pull request #1341 from hashicorp/f-rds-update
provider/aws: Add non-destructive updates to AWS RDS
This commit is contained in:
commit
e851751521
|
@ -49,7 +49,6 @@ func resourceAwsDbInstance() *schema.Resource {
|
||||||
"engine_version": &schema.Schema{
|
"engine_version": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"storage_encrypted": &schema.Schema{
|
"storage_encrypted": &schema.Schema{
|
||||||
|
@ -121,7 +120,6 @@ func resourceAwsDbInstance() *schema.Resource {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
ForceNew: true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"port": &schema.Schema{
|
"port": &schema.Schema{
|
||||||
|
@ -172,7 +170,6 @@ func resourceAwsDbInstance() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
ForceNew: true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"address": &schema.Schema{
|
"address": &schema.Schema{
|
||||||
|
@ -189,6 +186,16 @@ func resourceAwsDbInstance() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// apply_immediately is used to determine when the update modifications
|
||||||
|
// take place.
|
||||||
|
// See http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Modifying.html
|
||||||
|
"apply_immediately": &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
|
||||||
"tags": tagsSchema(),
|
"tags": tagsSchema(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -427,6 +434,41 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
|
||||||
conn := meta.(*AWSClient).rdsconn
|
conn := meta.(*AWSClient).rdsconn
|
||||||
|
|
||||||
d.Partial(true)
|
d.Partial(true)
|
||||||
|
// Change is used to determine if a ModifyDBInstanceMessage request actually
|
||||||
|
// gets sent.
|
||||||
|
change := false
|
||||||
|
|
||||||
|
req := &rds.ModifyDBInstanceMessage{
|
||||||
|
ApplyImmediately: aws.Boolean(d.Get("apply_immediately").(bool)),
|
||||||
|
DBInstanceIdentifier: aws.String(d.Id()),
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("engine_version") {
|
||||||
|
change = true
|
||||||
|
d.SetPartial("engine_version")
|
||||||
|
req.EngineVersion = aws.String(d.Get("engine_version").(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("multi_az") {
|
||||||
|
change = true
|
||||||
|
d.SetPartial("multi_az")
|
||||||
|
req.MultiAZ = aws.Boolean(d.Get("multi_az").(bool))
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("parameter_group_name") {
|
||||||
|
change = true
|
||||||
|
d.SetPartial("parameter_group_name")
|
||||||
|
req.DBParameterGroupName = aws.String(d.Get("parameter_group_name").(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
if change {
|
||||||
|
log.Printf("[DEBUG] DB Instance Modification request: %#v", req)
|
||||||
|
_, err := conn.ModifyDBInstance(req)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error mofigying DB Instance %s: %s", d.Id(), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if arn, err := buildRDSARN(d, meta); err == nil {
|
if arn, err := buildRDSARN(d, meta); err == nil {
|
||||||
if err := setTagsRDS(conn, d, arn); err != nil {
|
if err := setTagsRDS(conn, d, arn); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -62,6 +62,9 @@ The following arguments are supported:
|
||||||
* `db_subnet_group_name` - (Optional) Name of DB subnet group
|
* `db_subnet_group_name` - (Optional) Name of DB subnet group
|
||||||
* `parameter_group_name` - (Optional) Name of the DB parameter group to associate.
|
* `parameter_group_name` - (Optional) Name of the DB parameter group to associate.
|
||||||
* `storage_encrypted` - (Optional) Specifies whether the DB instance is encrypted. The Default is `false` if not specified.
|
* `storage_encrypted` - (Optional) Specifies whether the DB instance is encrypted. The Default is `false` if not specified.
|
||||||
|
* `apply_immediately` - (Optional) Specifies whether any database modifications
|
||||||
|
are applied immediately, or during the next maintenance window. Default is
|
||||||
|
`False`. See [Amazon RDS Documentation for more for more information.](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Modifying.html)
|
||||||
|
|
||||||
## Attributes Reference
|
## Attributes Reference
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue