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

feat: Adds support for disabling Backup Compliance Policy on resource delete #2953

Merged
merged 5 commits into from
Jan 14, 2025
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
3 changes: 3 additions & 0 deletions .changelog/2953.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/mongodbatlas_backup_compliance_policy: Adds support for disabling Backup Compliance Policy on resource delete
```
2 changes: 1 addition & 1 deletion docs/resources/backup_compliance_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ When enabled, the Backup Compliance Policy will be applied as the minimum backup

-> **NOTE:** Groups and projects are synonymous terms. You might find `groupId` in the official documentation.

-> **IMPORTANT NOTE:** Once enable a Backup Compliance Policy, no user, regardless of role, can disable the Backup Compliance Policy via Terraform, or any other method, without contacting MongoDB support. This means that once enabled some resources defined in Terraform will no longer be modifiable. See the full list of [Backup Compliance Policy Prohibited Actions and Considerations](https://www.mongodb.com/docs/atlas/backup/cloud-backup/backup-compliance-policy/#configure-a-backup-compliance-policy)
-> **IMPORTANT NOTE:** Once a Backup Compliance Policy is enabled, no user, regardless of role, can disable the Backup Compliance Policy via Terraform, or any other method, without contacting MongoDB Support. However, if the Backup Compliance Policy is approved for disablement by MongoDB Support, the resource can be removed and the delete operation will successfully disable the Backup Compliance Policy. With Backup Compliance Policy enabled, some resources defined in Terraform will no longer be modifiable. See the full list of [Backup Compliance Policy Prohibited Actions and Considerations](https://www.mongodb.com/docs/atlas/backup/cloud-backup/backup-compliance-policy/#configure-a-backup-compliance-policy).

-> **NOTE:** With Backup Compliance Policy enabled, cluster backups are retained after a cluster is deleted and backups can be used normally until retention expiration. When the Backup Compliance Policy is not enabled, Atlas deletes the cluster's associated backup snapshots when a cluster is terminated. By default, a Backup Compliance Policy is not enabled. For more details see [Back Up, Restore, and Archive Data](https://www.mongodb.com/docs/atlas/backup-restore-cluster/).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"log"
"net/http"
"strings"

Expand All @@ -21,6 +20,7 @@ import (

const (
errorBackupPolicyUpdate = "error updating a Backup Compliance Policy: %s: %s"
errorBackupPolicyDelete = "error disabling the Backup Compliance Policy: %s: %s"
errorBackupPolicyRead = "error getting a Backup Compliance Policy for the project(%s): %s"
errorBackupPolicySetting = "error setting `%s` for Backup Compliance Policy : %s: %s"
errorSnapshotBackupPolicySetting = "error setting `%s` for Cloud Provider Snapshot Backup Policy(%s): %s"
Expand Down Expand Up @@ -377,12 +377,12 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.
}

func resourceDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
// There is no resource to delete a backup compliance policy, it can only be updated.
log.Printf("[WARN] Note: Deleting a Backup Compliance Policy resource in Terraform does not remove the policy from your Atlas Project. " +
"To disable a Backup Compliance Policy, the security or legal representative specified for the Backup Compliance Policy must contact " +
"MongoDB Support and complete an extensive verification process. ")

d.SetId("")
connV2 := meta.(*config.MongoDBClient).AtlasV2
themantissa marked this conversation as resolved.
Show resolved Hide resolved
projectID := d.Get("project_id").(string)
_, _, err := connV2.CloudBackupsApi.DisableDataProtectionSettings(ctx, projectID).Execute()
if err != nil {
return diag.FromErr(fmt.Errorf(errorBackupPolicyDelete, projectID, err))
}
return nil
}

Expand Down
Loading