From 58907f8bbf3e2712d66a2154472c78702f1dd7c6 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Fri, 10 Jan 2025 12:09:41 +0100 Subject: [PATCH 1/5] add delete operation call --- .../resource_backup_compliance_policy.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/backupcompliancepolicy/resource_backup_compliance_policy.go b/internal/service/backupcompliancepolicy/resource_backup_compliance_policy.go index 6bbf0572cc..5c0603bc41 100644 --- a/internal/service/backupcompliancepolicy/resource_backup_compliance_policy.go +++ b/internal/service/backupcompliancepolicy/resource_backup_compliance_policy.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "log" "net/http" "strings" @@ -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" @@ -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 + 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 } From a077605477e18b5d96bd2cd8537fd7f41720db6a Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Fri, 10 Jan 2025 12:15:11 +0100 Subject: [PATCH 2/5] clarify in documentation new delete functionality --- docs/resources/backup_compliance_policy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/backup_compliance_policy.md b/docs/resources/backup_compliance_policy.md index cc2320df87..186553bcee 100644 --- a/docs/resources/backup_compliance_policy.md +++ b/docs/resources/backup_compliance_policy.md @@ -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. Only once approved for disablement from support, the resource can be removed and the delete operation will successfully disable the Backup Compliance Policy. 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). -> **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/). From 77379e7b1eaddeca39340bedb67953f017d2955d Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Fri, 10 Jan 2025 12:19:36 +0100 Subject: [PATCH 3/5] add changelog --- .changelog/2953.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/2953.txt diff --git a/.changelog/2953.txt b/.changelog/2953.txt new file mode 100644 index 0000000000..a90d96a925 --- /dev/null +++ b/.changelog/2953.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/mongodbatlas_backup_compliance_policy: Adds support for disabling Backup Compliance Policy on resource delete +``` From 870a6672ba2c837d37a4b99753fab680bbb89060 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Mon, 13 Jan 2025 10:44:29 +0100 Subject: [PATCH 4/5] Update docs/resources/backup_compliance_policy.md Co-authored-by: Melissa Plunkett --- docs/resources/backup_compliance_policy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/backup_compliance_policy.md b/docs/resources/backup_compliance_policy.md index 186553bcee..4dda686224 100644 --- a/docs/resources/backup_compliance_policy.md +++ b/docs/resources/backup_compliance_policy.md @@ -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 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. Only once approved for disablement from support, the resource can be removed and the delete operation will successfully disable the Backup Compliance Policy. 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 BCP is approved for disablement via the support process, 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/). From bf28b062dfd691616a346c486a962abca028d604 Mon Sep 17 00:00:00 2001 From: Agustin Bettati Date: Mon, 13 Jan 2025 17:59:26 +0100 Subject: [PATCH 5/5] applying doc feedback --- docs/resources/backup_compliance_policy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/backup_compliance_policy.md b/docs/resources/backup_compliance_policy.md index 4dda686224..76b387f01e 100644 --- a/docs/resources/backup_compliance_policy.md +++ b/docs/resources/backup_compliance_policy.md @@ -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 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 BCP is approved for disablement via the support process, 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). +-> **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/).