Possibility to change 'frequency_type' of snapshot backup policy item via Terraform
I’m facing an issue about Snapshot Backup Policy creation/modification via Terraform ( FYI, I open a case to the support of MongoDB https://support.mongodb.com/case/00668262). Let me explain :
When I want to create a MongoAtlas Cluster via terraform, I want to apply a custom Snahsphot Backup Policy with ONLY 2 items during the creation of the cluster :
N° Item Frequency type Frequency Retention
0 Daily 1 7 Days
1 Weekly 1 (Saturday) 4 weeks
However, during the creation of the mongo atlas cluster, I can see an error
Error: Error applying plan:
1 error occurred:
* module.clustercontrib.module.dpjmongoatlas.module.tfmodule-gcp-mongo-atlas-cluster.mongodbatlascloudprovidersnapshotbackuppolicy.snapshotbackup: 1 error occurred:
* mongodbatlascloudprovidersnapshotbackuppolicy.snapshot_backup: error updating a Cloud Provider Snapshot Backup Policy: PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/XXXXXXXXXXXXXXXXX/clusters/contrib/backup/schedule: 400 (request "Bad Request") The frequency type of a policy item must not be changed.
Indeed, during the creation of the MongoAtlas cluster, MongoAtlas apply the default Snapshot Backup Policy first (with 4 items hourly, daily, weekly, monthly) and after try to apply the custom snapshot backup policy I want (described in the terraform code). But, as we can see above, it seems impossible to change the frequency_type of an existing policy’s item…
To resume clearly with this spreadsheet :
N° Item Frequencytype of default policy Frequencytype of custom policy I want COMMENT
0 Hourly Daily KO (because The frequency type of a policy item must not be changed)
1 Daily Weekly KO (because The frequency type of a policy item must not be changed)
2 Weekly NOTHING
3 Monthly NOTHING
Can we purpose a evolution to have the possibilty to modify the frequency_type of an existing policy item via Terraform/API?
The Cloud Backup policy has been completely reworked as of provider version 1.0.0, with a few more fixes in 1.0.1 (coming shortly). This should address the pain points that have been raised here and elsewhere.
Want to update those voting here - we've discussed how the cloud backup policy was implemented and due to feedback plan to re-architect it. Will continue to provide updates as we get closer to that work. Thank you!
Thank you for posting your feedback. Based on this and other feedback we've updated the documentation with better examples of how to modify the backup policy, which will go out with our next release. However you can see the PR here: https://github.com/mongodb/terraform-provider-mongodbatlas/pull/259/files. If you have a chance to check it out we'd appreciate feedback!