Adding skip_final_snapshop bool to th db_instance. This will allow us to specify whether a snapshot is needed directly rather than checking for an empty string

This commit is contained in:
stack72 2015-11-10 23:05:07 +00:00
parent 7f734d58cd
commit 5796b13373
2 changed files with 12 additions and 5 deletions

View File

@ -188,6 +188,12 @@ func resourceAwsDbInstance() *schema.Resource {
},
},
"skip_final_snapshot": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"copy_tags_to_snapshot": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
@ -619,11 +625,11 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error
opts := rds.DeleteDBInstanceInput{DBInstanceIdentifier: aws.String(d.Id())}
finalSnapshot := d.Get("final_snapshot_identifier").(string)
if finalSnapshot == "" {
opts.SkipFinalSnapshot = aws.Bool(true)
} else {
opts.FinalDBSnapshotIdentifier = aws.String(finalSnapshot)
skipFinalSnapshot := d.Get("skip_final_snapshot").(bool)
opts.SkipFinalSnapshot = aws.Bool(skipFinalSnapshot)
if name, present := d.GetOk("final_snapshot_identifier"); present && !skipFinalSnapshot {
opts.FinalDBSnapshotIdentifier = aws.String(name.(string))
}
log.Printf("[DEBUG] DB Instance destroy configuration: %v", opts)

View File

@ -45,6 +45,7 @@ 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.
* `skip_final_snapshot` - (Optional) Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted. Default is false.
* `copy_tags_to_snapshot` (Optional, boolean) On delete, copy all Instance `tags` to
the final snapshot (if `final_snapshot_identifier` is specified). Default
`false`