Skip to content

Commit

Permalink
Adding skip_final_snapshop bool to th db_instance. This will allow us…
Browse files Browse the repository at this point in the history
… to specify whether a snapshot is needed directly rather than checking for an empty string
  • Loading branch information
stack72 committed Nov 10, 2015
1 parent d1d8aca commit 174fb20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions builtin/providers/aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,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,
Expand Down Expand Up @@ -605,11 +611,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit 174fb20

Please sign in to comment.