Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions builtin/providers/aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ func resourceAwsRDSCluster() *schema.Resource {
},
},

"skip_final_snapshot": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: true,
},

"master_username": &schema.Schema{
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -372,12 +378,15 @@ func resourceAwsRDSClusterDelete(d *schema.ResourceData, meta interface{}) error
DBClusterIdentifier: aws.String(d.Id()),
}

finalSnapshot := d.Get("final_snapshot_identifier").(string)
if finalSnapshot == "" {
deleteOpts.SkipFinalSnapshot = aws.Bool(true)
} else {
deleteOpts.FinalDBSnapshotIdentifier = aws.String(finalSnapshot)
deleteOpts.SkipFinalSnapshot = aws.Bool(false)
skipFinalSnapshot := d.Get("skip_final_snapshot").(bool)
deleteOpts.SkipFinalSnapshot = aws.Bool(skipFinalSnapshot)

if skipFinalSnapshot == false {
if name, present := d.GetOk("final_snapshot_identifier"); present {
deleteOpts.FinalDBSnapshotIdentifier = aws.String(name.(string))
} else {
return fmt.Errorf("RDS Cluster FinalSnapshotIdentifier is required when a final snapshot is required")
}
}

log.Printf("[DEBUG] RDS Cluster delete options: %s", deleteOpts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ string.
* `final_snapshot_identifier` - (Optional) The name of your final DB snapshot
when this DB cluster 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 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
instances in the DB cluster can be created in
* `backup_retention_period` - (Optional) The days to retain backups for. Default
Expand Down