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
244 stars 170 forks source link

Cannot re-apply config when M2/M5 `disk_size_gb` is specified incorrectly #115

Closed mattt416 closed 4 years ago

mattt416 commented 4 years ago

Hi team,

The M2/M5 tiers have fixed disk storage, 2 GB for M2 and 5 GB for M5.

If I add any arbitrary disk_size_gb value to my M2/M5 config, the build goes through without issue.

However, after the build completes and I attempt to re-apply, I receive the following failure:

400 (request "Bad Request") Cannot update a M0/M2/M5 cluster through the public API.

This is because the re-apply tries to change the disk_size_gb from what it ought to be to what I've configured:

      ~ disk_size_gb                 = 5 -> 10

Would it make sense to enforce the correct disk_size_gb values for M2/M5 up front to prevent this from occurring?

Thanks, Matt

themantissa commented 4 years ago

Thank you @mattt416. This is indeed a bug and in my own testing I've discovered a few more challenges with the shared Atlas tiers, that is M2/M5s, that I am adding here. The shared tier (TENANT) presents a specific set of challenges in that is it so very different than M10s and above in many of the API configuration options (documented here: https://docs.atlas.mongodb.com/reference/free-shared-limitations/ )

The following config will work to create an M2/M5, comments call out challenges/issues:

`resource "mongodbatlas_cluster" "test" { name = "testCluster" project_id = mongodbatlas_project.my_project.id

provider_name = "TENANT" backing_provider_name = "AWS" provider_region_name = "US_EAST_1" provider_instance_size_name = "M2" //disk_size_gb is required but should not be as it is a fixed number, it should either //be optional or, in order for it to work with upgrades, only accept the default values. disk_size_gb = "2" //version should be optional mongo_db_major_version = "4.2" //You can't auto scale storage with the shared tier so this always must be false //so should not be required. All the shared/ auto_scaling_disk_gb_enabled = "false" }`

I then tried to upgrade from an M2 to an M10, this caused the M2 to either be destroyed or the upgrade failed.

@marinsalinas and @PacoDw fyi we'll need to add this to our list of bugs to address. We'll need to ensure we can create a M2/M5 with only with applicable arguments (cannot update an M2 or M5 via API, going to update doc to reflect this.) Could still improve the variables required though.

themantissa commented 4 years ago

https://github.com/terraform-providers/terraform-provider-mongodbatlas/pull/119