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

mongodbatlas_cluster allows for name changing #676

Closed icco closed 2 years ago

icco commented 2 years ago

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.1.5
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.74.2
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/mongodb/mongodbatlas v1.2.0
+ provider registry.terraform.io/sumologic/sumologic v2.12.0

Terraform Configuration File

# Copy-paste your configuration info here

Steps to Reproduce

  1. Create a mongodbatlas_cluster in tf
  2. Change the name
  3. Apply

Expected Behavior

Terraform should show a recreate warning, as name changes are not allowed in MongoDB Atlas.

Actual Behavior

The cluster name and connection strings change.

Debug Output

Crash Output

Additional Context

References

nikhil-mongo commented 2 years ago
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # mongodbatlas_cluster.cluster-atlas will be updated in-place
  ~ resource "mongodbatlas_cluster" "cluster-atlas" {
        id                                      = "Y2x1c3Rlcl9pZA==:NjIwZGNiMTU5Mjg1NzIzMDM5NzhjZTA1-Y2x1c3Rlcl9uYW1l:Y2x1c3Rlci1hdGxhcw==-cHJvamVjdF9pZA==:NjEzMWExYjQ4MGUxZDAzODAwYjY0Yzlh-cHJvdmlkZXJfbmFtZQ==:QVdT"
      ~ name                                    = "cluster-atlas" -> "cluster-atlas-1"
        # (32 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

We are informing that the change will be done to change the cluster-name.

But the complete flow is as below -

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

mongodbatlas_cluster.cluster-atlas: Modifying... [id=Y2x1c3Rlcl9pZA==:NjIwZGNiMTU5Mjg1NzIzMDM5NzhjZTA1-Y2x1c3Rlcl9uYW1l:Y2x1c3Rlci1hdGxhcw==-cHJvamVjdF9pZA==:NjEzMWExYjQ4MGUxZDAzODAwYjY0Yzlh-cHJvdmlkZXJfbmFtZQ==:QVdT]
mongodbatlas_cluster.cluster-atlas: Modifications complete after 3s [id=Y2x1c3Rlcl9pZA==:NjIwZGNiMTU5Mjg1NzIzMDM5NzhjZTA1-Y2x1c3Rlcl9uYW1l:Y2x1c3Rlci1hdGxhcw==-cHJvamVjdF9pZA==:NjEzMWExYjQ4MGUxZDAzODAwYjY0Yzlh-cHJvdmlkZXJfbmFtZQ==:QVdT]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
 ~/Desktop/MyWork/git-676/ terraform apply
mongodbatlas_cluster.cluster-atlas: Refreshing state... [id=Y2x1c3Rlcl9pZA==:NjIwZGNiMTU5Mjg1NzIzMDM5NzhjZTA1-Y2x1c3Rlcl9uYW1l:Y2x1c3Rlci1hdGxhcw==-cHJvamVjdF9pZA==:NjEzMWExYjQ4MGUxZDAzODAwYjY0Yzlh-cHJvdmlkZXJfbmFtZQ==:QVdT]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
 ~/Desktop/MyWork/git-676/ 
themantissa commented 2 years ago

I'm actually going to close this as it was already reported in #189. I'll link to this report from there.