diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index d1d3a4ae1..b80a6cded 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -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{ Type: schema.TypeString, Optional: true, @@ -261,6 +267,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error if v, ok := d.GetOk("replicate_source_db"); ok { opts := rds.CreateDBInstanceReadReplicaInput{ SourceDBInstanceIdentifier: aws.String(v.(string)), + CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)), DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceIdentifier: aws.String(d.Get("identifier").(string)), Tags: tags, @@ -347,6 +354,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error } else { opts := rds.CreateDBInstanceInput{ 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)), DBInstanceClass: aws.String(d.Get("instance_class").(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_version", v.EngineVersion) d.Set("allocated_storage", v.AllocatedStorage) + d.Set("copy_tags_to_snapshot", v.CopyTagsToSnapshot) d.Set("storage_type", v.StorageType) d.Set("instance_class", v.DBInstanceClass) 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))) 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") { d.SetPartial("instance_class") req.DBInstanceClass = aws.String(d.Get("instance_class").(string)) diff --git a/website/source/docs/providers/aws/r/db_instance.html.markdown b/website/source/docs/providers/aws/r/db_instance.html.markdown index adf2dafe6..499e13ba4 100644 --- a/website/source/docs/providers/aws/r/db_instance.html.markdown +++ b/website/source/docs/providers/aws/r/db_instance.html.markdown @@ -45,6 +45,9 @@ The following arguments are supported: * `final_snapshot_identifier` - (Optional) The name of your final DB snapshot when this DB instance is deleted. If omitted, no final snapshot will be 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 initially. * `password` - (Required) Password for the master DB user. Note that this may