Skip to content

Commit

Permalink
provider/aws: Add support for Skipping Final Snapshot in RDS Cluster
Browse files Browse the repository at this point in the history
This works exactly the same as in DB Instance. We cannot use an empty
string to skip the final snapshot or we get the following error:

```
only alphanumeric characters and hyphens allowed in
"final_snapshot_identifier"
```

Therefore, we need to wrap this with another parameter. The we DO NOT
skip final snapshots by default as we currently create them right now
and this would change the user functionality
  • Loading branch information
stack72 committed May 20, 2016
1 parent fc022e8 commit 333984f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion 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: false,
},

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

skipFinalSnapshot := d.Get("skip_final_snapshot").(bool)
finalSnapshot := d.Get("final_snapshot_identifier").(string)
if finalSnapshot == "" {
if skipFinalSnapshot == true {
deleteOpts.SkipFinalSnapshot = aws.Bool(true)
} else {
deleteOpts.FinalDBSnapshotIdentifier = aws.String(finalSnapshot)
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. Default is false.
* `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

0 comments on commit 333984f

Please sign in to comment.