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

changing cluster to _NVME fails on commented-out IOPS #283

Closed in4mer closed 4 years ago

in4mer commented 4 years ago

Versions

Terraform v0.12.29

Situation

After creating an M40 cluster using mongodbatlas_cluster, with:

  disk_size_gb                  = 10
  provider_disk_iops            = 100
  provider_volume_type          = "STANDARD"

size_name was changed from M40 to M40_NVME, and the those earlier values were commented out:

#  disk_size_gb                  = 10
#  provider_disk_iops            = 100
#  provider_volume_type          = "STANDARD"

What happens

Error: error updating MongoDB Cluster (stage-legacydb-customerdata0): PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/5f22421af796b75b8b75b37f/clusters/stage-legacydb-customerdata0: 400 (request "Bad 
Request") The cluster's disk IOPS of 240 is invalid. For a disk of size 80GB on instance size M40_NVME with a volume type of STANDARD, the IOPS must be equal to 3000 for an NVMe cluster of this instance siz
e.

What I expect to happen

I expect the combination of size_name change plus the removal of non-nvme configuration values to elicit a plan which successfully transitions the cluster to an NVME-backed storage class.

The commented-out values should no longer be considered authorative for the resource definition. I tried commenting them out, and re-applying with a size of "M40", but this plan elicited no changes. Subsequent change to "_NVME" of course created the same error.

themantissa commented 4 years ago

Hi @in4mer, thank you for the details in the issue! I think this just needs a few adjustments. Since you are actually changing storage types from standard to provisioned you need to change two of those values as opposed to commenting them out, e.g.: # disk_size_gb = 10 provider_instance_size_name = "M40_NVME" provider_disk_iops = 3000 provider_volume_type = "PROVISIONED"

Let me know if that unblocks you.

themantissa commented 4 years ago

@in4mer assuming the earlier answer helped unblock you. If not let me know.

in4mer commented 4 years ago

Whoops, forgot to hit submit.

Yep it helped, thank you. In lieu of the provider handling this, is there some documentation I missed?

themantissa commented 4 years ago

Good question, the attribute definitions cover it somewhat but I can see that wouldn't be obvious without knowing the API a bit more. Seems an example for creating/upgrading to an NVME option would be a good add :) I'll add that to our list of improvements. Thank you @in4mer!