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
240 stars 168 forks source link

Confusing output when modifying a cluster #186

Closed c-ameron closed 4 years ago

c-ameron commented 4 years ago

Hi,

I'm trying to add in an analytics node to an existing cluster in the mongodbatlas_cluster resource. In this case, I'm having to port my configuration from an 'Example AWS cluster', to a 'Example Multi-Region cluster'.

-  num_shards             = 1
-  provider_region_name = "xy"

+
+  cluster_type = "REPLICASET"
+
+  # Any hardcoded values are defaults from the API
+  replication_specs {
+    num_shards = 1
+    zone_name  = "Zone 1"
+    regions_config {
+      region_name     = "xy"
+      electable_nodes = 3
+      priority        = 7
+      read_only_nodes = 0
+      analytics_nodes = 1
+    }
+  }

This should in theory simply be adding in an analytics node (if I set it analytics_nodes = 0, there's no change). However, the output from Terraform is a little confusing. It looks like you're recreating the cluster.

      ~ replication_specs {
            id         = "xx"
            num_shards = 1
            zone_name  = "Zone 1"

          - regions_config {
              - analytics_nodes = 0 -> null
              - electable_nodes = 3 -> null
              - priority        = 7 -> null
              - read_only_nodes = 0 -> null
              - region_name     = "xy" -> null
            }
          + regions_config {
              + analytics_nodes = 1
              + electable_nodes = 3
              + priority        = 7
              + read_only_nodes = 0
              + region_name     = "xy"
            }
        }

Could you please confirm that this won't recreate my existing cluster?

Having a look through the API docs, it looks like Modifying a Cluster is a PATCH, so in theory it should be in place. Is that correct?

Thanks for your hard work!!

c-ameron commented 4 years ago

I just tried this out. It didn't delete any existing node.

I also spoke with Atlas who confirmed that even if nodes were deleted, then it would be done in a rolling fashion, with keeping the same storage.

Happy to close this.

themantissa commented 4 years ago

@c-ameron thank you for the question and for solving it too! Hope all is going well. Closing as requested.