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 e99e438
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 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,10 +611,10 @@ 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 {
skipFinalSnapshot := d.Get("skip_final_snapshot").(bool)
opts.SkipFinalSnapshot = aws.Bool(skipFinalSnapshot)
if !skipFinalSnapshot && d.Get("final_snapshot_identifier").(string) != "" {
finalSnapshot := d.Get("final_snapshot_identifier").(string)
opts.FinalDBSnapshotIdentifier = aws.String(finalSnapshot)
}

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 e99e438

Please sign in to comment.