mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
241 stars 167 forks source link

CANNOT_DISABLE_PIT_WITH_BACKUP_COMPLIANCE_POLICY #1855

Closed mvaduguru87 closed 8 months ago

mvaduguru87 commented 8 months ago

Terraform CLI and Terraform MongoDB Atlas Provider Version

 Terraform Version 1.6.4
Terraform MongoDB Atlas Provider Version 1.14.0

Terraform Edition

Terraform OSS

Terraform Configuration File

#resource "mongodbatlas_backup_compliance_policy" "this" {
  count                      = var.enabled ? 1 : 0
  project_id                 = var.project_id
  authorized_email           = ###
  copy_protection_enabled    = false
  pit_enabled                = true
  encryption_at_rest_enabled = false
  authorized_user_first_name = "###"
  authorized_user_last_name = "###"
restore_window_days = var.restore_window_days
...
}

Steps to Reproduce

Plan/Apply 

Actual Behavior

When the flag enabled is set to true , the plan is getting generated but when applying the plugin is crashing. plugincrash.log

When the flag enabled is set to false , the plan is getting generated but when applying getting the error Error: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/65a8075d15a5527895928ac4/clusters: 400 (request "CANNOT_DISABLE_PIT_WITH_BACKUP_COMPLIANCE_POLICY") Continuous Cloud Backup is required by Backup Compliance Policy. Screenshot 2024-01-18 at 5 43 42 PM

-->

Debug Output

Crash Output

Additional Context

References

(https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/backup_compliance_policy)

github-actions[bot] commented 8 months ago

Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:

The ticket CLOUDP-224356 was created for internal tracking.

maastha commented 8 months ago

Hi @mvaduguru87 Thank you for creating this issue, I could not reproduce this and was able to successfully update pit_enabled to true.

Could you please help us with below details to look further into this issue?

I would also request you to provide further details to help with one-click reproducible issues principle as mentioned in our guidelines.

mvaduguru87 commented 8 months ago

Certainly!. We are using modules to create the clusters. Hence I am providing you with the output of the plan that still provides you cluster configuration. Please find attached file terraformplan_1_14_0.txt for the details. terraformplan_1_14_0.txt

I am also attaching the trace logs. terraform_1.14_1_trace.log terraform_1_14_1_trace.log

I also want to mention that since all our clusters that have already been created are using V1.13.1 mongo db provider version, I tried to use the same to run the clusters. I received the same error. I am attaching the configurations in file and tracelogs. terraformplan_1_13_1.txt terraform_1_13_1__v1_trace.log

The error in all these cases is same - Error: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/65a8075d15a5527895928ac4/clusters: 400 (request "CANNOT_DISABLE_PIT_WITH_BACKUP_COMPLIANCE_POLICY") Continuous Cloud Backup is required by Backup Compliance Policy.

Please let me know if you need any more details. Unfortunately I couldn't provide you a one -click reproducible files. I hope what is provided will help to identity the issue.

Also please note that I removed all the sensitive information from the trace files.

maastha commented 8 months ago

Hi @mvaduguru87

I was able to reproduce panic: interface conversion: interface {} is nil, not string error in v1.14.0. This is already fixed in https://github.com/mongodb/terraform-provider-mongodbatlas/pull/1803 (see comment) and would be available in our next release planned in the next few weeks.

As for CANNOT_DISABLE_PIT_WITH_BACKUP_COMPLIANCE_POLICY error when creating the cluster, I'd request you to open a HELP support ticket https://support.mongodb.com/ to get support from the appropriate team as this seems like an issue with the way backup compliance policy and the cluster are configured.

Note that I am not sure of the exact order in which updates were performed, but with the fix mentioned above I was able to successfully create a cluster with same configuration as yours (with mongodbatlas_backup_compliance_policy.pit_enabled = true) but received below error if I tried to update it to false

Error: error updating a Backup Compliance Policy: xxxxx: PUT https://cloud-dev.mongodb.com/api/atlas/v1.0/groups/xxxxxx/backupCompliancePolicy: 400 (request "BACKUP_COMPLIANCE_POLICY_SETTINGS_INVALID") Invalid Backup Compliance Policy settings: a support ticket is required to turn off point-in-time option or decrease the restore window.
mvaduguru87 commented 8 months ago

Thank you for your response. When are you planning to release the next fix?