Merge pull request #3529 from hashicorp/b-aws-rds-copy-tags-to-snapshots

provider/aws: Add configuration to enable copying RDS tags to final snapshot
This commit is contained in:
Clint 2015-10-30 09:09:41 -05:00
commit 4db8ef4a45
2 changed files with 17 additions and 0 deletions

View File

@ -182,6 +182,12 @@ func resourceAwsDbInstance() *schema.Resource {
}, },
}, },
"copy_tags_to_snapshot": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"db_subnet_group_name": &schema.Schema{ "db_subnet_group_name": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
@ -261,6 +267,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
if v, ok := d.GetOk("replicate_source_db"); ok { if v, ok := d.GetOk("replicate_source_db"); ok {
opts := rds.CreateDBInstanceReadReplicaInput{ opts := rds.CreateDBInstanceReadReplicaInput{
SourceDBInstanceIdentifier: aws.String(v.(string)), SourceDBInstanceIdentifier: aws.String(v.(string)),
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceClass: aws.String(d.Get("instance_class").(string)),
DBInstanceIdentifier: aws.String(d.Get("identifier").(string)), DBInstanceIdentifier: aws.String(d.Get("identifier").(string)),
Tags: tags, Tags: tags,
@ -347,6 +354,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
} else { } else {
opts := rds.CreateDBInstanceInput{ opts := rds.CreateDBInstanceInput{
AllocatedStorage: aws.Int64(int64(d.Get("allocated_storage").(int))), AllocatedStorage: aws.Int64(int64(d.Get("allocated_storage").(int))),
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
DBName: aws.String(d.Get("name").(string)), DBName: aws.String(d.Get("name").(string)),
DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceClass: aws.String(d.Get("instance_class").(string)),
DBInstanceIdentifier: aws.String(d.Get("identifier").(string)), DBInstanceIdentifier: aws.String(d.Get("identifier").(string)),
@ -467,6 +475,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
d.Set("engine", v.Engine) d.Set("engine", v.Engine)
d.Set("engine_version", v.EngineVersion) d.Set("engine_version", v.EngineVersion)
d.Set("allocated_storage", v.AllocatedStorage) d.Set("allocated_storage", v.AllocatedStorage)
d.Set("copy_tags_to_snapshot", v.CopyTagsToSnapshot)
d.Set("storage_type", v.StorageType) d.Set("storage_type", v.StorageType)
d.Set("instance_class", v.DBInstanceClass) d.Set("instance_class", v.DBInstanceClass)
d.Set("availability_zone", v.AvailabilityZone) d.Set("availability_zone", v.AvailabilityZone)
@ -619,6 +628,11 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
req.BackupRetentionPeriod = aws.Int64(int64(d.Get("backup_retention_period").(int))) req.BackupRetentionPeriod = aws.Int64(int64(d.Get("backup_retention_period").(int)))
requestUpdate = true requestUpdate = true
} }
if d.HasChange("copy_tags_to_snapshot") {
d.SetPartial("copy_tags_to_snapshot")
req.CopyTagsToSnapshot = aws.Bool(d.Get("copy_tags_to_snapshot").(bool))
requestUpdate = true
}
if d.HasChange("instance_class") { if d.HasChange("instance_class") {
d.SetPartial("instance_class") d.SetPartial("instance_class")
req.DBInstanceClass = aws.String(d.Get("instance_class").(string)) req.DBInstanceClass = aws.String(d.Get("instance_class").(string))

View File

@ -45,6 +45,9 @@ The following arguments are supported:
* `final_snapshot_identifier` - (Optional) The name of your final DB snapshot * `final_snapshot_identifier` - (Optional) The name of your final DB snapshot
when this DB instance is deleted. If omitted, no final snapshot will be when this DB instance is deleted. If omitted, no final snapshot will be
made. made.
* `copy_tags_to_snapshot` (Optional, boolean) On delete, copy all Instance `tags` to
the final snapshot (if `final_snapshot_identifier` is specified). Default
`false`
* `name` - (Optional) The DB name to create. If omitted, no database is created * `name` - (Optional) The DB name to create. If omitted, no database is created
initially. initially.
* `password` - (Required) Password for the master DB user. Note that this may * `password` - (Required) Password for the master DB user. Note that this may