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:
parent
7f734d58cd
commit
5796b13373
|
@ -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{
|
"copy_tags_to_snapshot": &schema.Schema{
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
@ -619,11 +625,11 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error
|
||||||
|
|
||||||
opts := rds.DeleteDBInstanceInput{DBInstanceIdentifier: aws.String(d.Id())}
|
opts := rds.DeleteDBInstanceInput{DBInstanceIdentifier: aws.String(d.Id())}
|
||||||
|
|
||||||
finalSnapshot := d.Get("final_snapshot_identifier").(string)
|
skipFinalSnapshot := d.Get("skip_final_snapshot").(bool)
|
||||||
if finalSnapshot == "" {
|
opts.SkipFinalSnapshot = aws.Bool(skipFinalSnapshot)
|
||||||
opts.SkipFinalSnapshot = aws.Bool(true)
|
|
||||||
} else {
|
if name, present := d.GetOk("final_snapshot_identifier"); present && !skipFinalSnapshot {
|
||||||
opts.FinalDBSnapshotIdentifier = aws.String(finalSnapshot)
|
opts.FinalDBSnapshotIdentifier = aws.String(name.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] DB Instance destroy configuration: %v", opts)
|
log.Printf("[DEBUG] DB Instance destroy configuration: %v", opts)
|
||||||
|
|
|
@ -45,6 +45,7 @@ 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.
|
||||||
|
* `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
|
* `copy_tags_to_snapshot` – (Optional, boolean) On delete, copy all Instance `tags` to
|
||||||
the final snapshot (if `final_snapshot_identifier` is specified). Default
|
the final snapshot (if `final_snapshot_identifier` is specified). Default
|
||||||
`false`
|
`false`
|
||||||
|
|
Loading…
Reference in New Issue