provider/aws: Add support for Skipping Final Snapshot in RDS Cluster (#6795)

* provider/aws: Add support for Skipping Final Snapshot in RDS Cluster
This commit is contained in:
Paul Stack 2016-05-20 18:52:26 +01:00 committed by Clint
parent 890eebabc4
commit ec8c242ebf
2 changed files with 16 additions and 6 deletions

View File

@ -103,6 +103,12 @@ func resourceAwsRDSCluster() *schema.Resource {
}, },
}, },
"skip_final_snapshot": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"master_username": &schema.Schema{ "master_username": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
@ -372,12 +378,15 @@ func resourceAwsRDSClusterDelete(d *schema.ResourceData, meta interface{}) error
DBClusterIdentifier: aws.String(d.Id()), DBClusterIdentifier: aws.String(d.Id()),
} }
finalSnapshot := d.Get("final_snapshot_identifier").(string) skipFinalSnapshot := d.Get("skip_final_snapshot").(bool)
if finalSnapshot == "" { deleteOpts.SkipFinalSnapshot = aws.Bool(skipFinalSnapshot)
deleteOpts.SkipFinalSnapshot = aws.Bool(true)
if skipFinalSnapshot == false {
if name, present := d.GetOk("final_snapshot_identifier"); present {
deleteOpts.FinalDBSnapshotIdentifier = aws.String(name.(string))
} else { } else {
deleteOpts.FinalDBSnapshotIdentifier = aws.String(finalSnapshot) return fmt.Errorf("RDS Cluster FinalSnapshotIdentifier is required when a final snapshot is required")
deleteOpts.SkipFinalSnapshot = aws.Bool(false) }
} }
log.Printf("[DEBUG] RDS Cluster delete options: %s", deleteOpts) log.Printf("[DEBUG] RDS Cluster delete options: %s", deleteOpts)

View File

@ -61,6 +61,7 @@ string.
* `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 cluster is deleted. If omitted, no final snapshot will be when this DB cluster 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 cluster is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from `final_snapshot_identifier`. Default is true.
* `availability_zones` - (Optional) A list of EC2 Availability Zones that * `availability_zones` - (Optional) A list of EC2 Availability Zones that
instances in the DB cluster can be created in instances in the DB cluster can be created in
* `backup_retention_period` - (Optional) The days to retain backups for. Default * `backup_retention_period` - (Optional) The days to retain backups for. Default