Skip to content

Commit

Permalink
Merge pull request #34309 from xiaxuantan/aurora-delete-automated-bac…
Browse files Browse the repository at this point in the history
…kups

Automated backups can be retained when deleting Aurora clusters.
  • Loading branch information
ewbankkit authored Nov 10, 2023
2 parents 2f0d5dd + 21b5dfe commit 8e6e118
Show file tree
Hide file tree
Showing 8 changed files with 554 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/34309.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_rds_cluster: Add `delete_automated_backups` argument
```
21 changes: 19 additions & 2 deletions internal/service/rds/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ func ResourceCluster() *schema.Resource {
Delete: schema.DefaultTimeout(120 * time.Minute),
},

SchemaVersion: 1,
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceClusterResourceV0().CoreConfigSchema().ImpliedType(),
Upgrade: clusterStateUpgradeV0,
Version: 0,
},
},

Schema: map[string]*schema.Schema{
"allocated_storage": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -157,6 +166,11 @@ func ResourceCluster() *schema.Resource {
ForceNew: true,
Computed: true,
},
"delete_automated_backups": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"deletion_protection": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -1219,6 +1233,7 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int

if d.HasChangesExcept(
"allow_major_version_upgrade",
"delete_automated_backups",
"final_snapshot_identifier",
"global_cluster_identifier",
"iam_roles",
Expand Down Expand Up @@ -1470,8 +1485,9 @@ func resourceClusterDelete(ctx context.Context, d *schema.ResourceData, meta int

skipFinalSnapshot := d.Get("skip_final_snapshot").(bool)
input := &rds.DeleteDBClusterInput{
DBClusterIdentifier: aws.String(d.Id()),
SkipFinalSnapshot: aws.Bool(skipFinalSnapshot),
DBClusterIdentifier: aws.String(d.Id()),
DeleteAutomatedBackups: aws.Bool(d.Get("delete_automated_backups").(bool)),
SkipFinalSnapshot: aws.Bool(skipFinalSnapshot),
}

if !skipFinalSnapshot {
Expand Down Expand Up @@ -1554,6 +1570,7 @@ func resourceClusterImport(_ context.Context, d *schema.ResourceData, meta inter
// from any API call, so we need to default skip_final_snapshot to true so
// that final_snapshot_identifier is not required
d.Set("skip_final_snapshot", true)
d.Set("delete_automated_backups", true)
return []*schema.ResourceData{d}, nil
}

Expand Down
Loading

0 comments on commit 8e6e118

Please sign in to comment.