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 169 forks source link

num_shards value changed to 1 #970

Closed jmeagheriv closed 1 year ago

jmeagheriv commented 1 year ago

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v0.13.7
+ provider registry.terraform.io/mongodb/mongodbatlas v1.6.1

Terraform Configuration File

resource "mongodbatlas_cluster" "cluster-test"
 project_id   = var.projid
 name         = "cluster-test"
 cluster_type = "SHARDED"
 replication_specs {
   num_shards = 3
   regions_config {
     region_name     = "US_EAST_1"
     electable_nodes = 3
     priority        = 7
     read_only_nodes = 0
   }
 }
 cloud_backup = true
 auto_scaling_disk_gb_enabled = true
 mongo_db_major_version       = "4.2"
 # Provider Settings "block"
 provider_name               = "AWS"
 disk_size_gb                = 100
 provider_instance_size_name = "M30"
}

Steps to Reproduce

Expected Behavior

No changes

Actual Behavior

  ~ num_shards                              = 3 -> 1

Number of shards reset to 1.

Debug Output

Crash Output

No Crash output

Additional Context

There are two different num_shards values in the plan output, one in replicationSpecs and one before that. If you have a sharded cluster and make any change except to num_shards it will revert the num_shards to 1. This issue could cause someone to remove shards erroneously.

References

https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/mongodbatlas/data_source_mongodbatlas_cluster.go

jmeagheriv commented 1 year ago

Updated the references it seems in this resource there is num_shards inside the replication_specs and outside it. If you set them both the issue doesn't occur but your config looks weird with the same variable set multiple times

martinstibbe commented 1 year ago

@jmeagheriv Investigating the overlap of parameters with engineering to determine best course of action

github-actions[bot] commented 1 year ago

This issue has gone 30 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 30 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

Zuhairahmed commented 1 year ago

@jmeagheriv this issue has been resolved in advanced_cluster resource with only 1 num_shards parameter within replicationSpecs block. For more details see here: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Multi-Cloud-Clusters/operation/listClusters

You are correct there are 2 num_shards parameters in cluster resource and would recommend in this case to adopt advanced_cluster resource where possible going forward. Closing issue, but feel free to re-open if you need anything else here.