terraform-provider-mongodbatlas: INVALID_CLUSTER_CONFIGURATION when adding new regions

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.0.5 on darwin_amd64
mongo provider: 1.0.0

Terraform Output

Terraform will perform the following actions:

  # mongodbatlas_cluster.runtime will be updated in-place
  ~ resource "mongodbatlas_cluster" "runtime" {
        id                                              = "********"
        name                                            = "prod"
        # (31 unchanged attributes hidden)



      - replication_specs {
          - id         = "******" -> null
          - num_shards = 1 -> null
          - zone_name  = "Zone 1" -> null

          - regions_config {
              - analytics_nodes = 0 -> null
              - electable_nodes = 3 -> null
              - priority        = 7 -> null
              - read_only_nodes = 0 -> null
              - region_name     = "EUROPE_WEST_4" -> null
            }
        }
      + replication_specs {
          + id         = (known after apply)
          + num_shards = 1
          + zone_name  = "Zone 1"

          + regions_config {
              + analytics_nodes = 0
              + electable_nodes = 0
              + priority        = 0
              + read_only_nodes = 2
              + region_name     = "SOUTHEASTERN_ASIA_PACIFIC"
            }
          + regions_config {
              + analytics_nodes = 0
              + electable_nodes = 3
              + priority        = 7
              + read_only_nodes = 0
              + region_name     = "EUROPE_WEST_4"
            }
        }
        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
mongodbatlas_cluster.runtime: Modifying... [id=****]
╷
│ Error: error updating MongoDB Cluster (runtime-prod): PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/*******/clusters/prod: 400 (request "INVALID_CLUSTER_CONFIGURATION") The specified cluster configuration is not valid.
│
│   with mongodbatlas_cluster.runtime,
│   on main.tf line 23, in resource "mongodbatlas_cluster" "runtime":
│   23: resource "mongodbatlas_cluster" "runtime" {
│

Steps to Reproduce

  1. Create a replicaset cluster
  2. Add a new read only region replica

Expected Behavior

New replica is added to the cluster or a meaningful error message appears

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 15

Most upvoted comments

I had same issue. Version 1.0.2 works perfect. Thanks

Terraform v1.0.7 on darwin_arm64 MongoDB Atlas Provider version 1.0.1

I have same issue when create new cluster and apply terraform again without change mongodbatlas_cluster resource.

Terraform configuration

resource "mongodbatlas_cluster" "test" {
  project_id   = var.mongodbatlas_project_id
  name         = "test-${var.environment}"
  cluster_type = "SHARDED"
  num_shards = 2
  replication_specs {
    num_shards = 2
    regions_config {
      region_name     = local.atlas_region
      electable_nodes = 3
      priority        = 7
      read_only_nodes = 0
    }
  }
  cloud_backup                 = true
  auto_scaling_disk_gb_enabled = true
  mongo_db_major_version       = "4.4"

  //Provider Settings "block"
  provider_name               = "AWS"
  disk_size_gb                = 40
  provider_instance_size_name = "M30"
}

Terraform Output

image image

Steps to Reproduce

  1. Create a shard cluster.
  2. Terraform apply without change mongodbatlas_cluster resource.

Expected Behavior

No change and no error from terraform.

This issue was resolve. Because I set the wrong region (AP-SOUTHEAST-1). It should be used underscore (_) to replace the dash (-).

@slamdev I will pass on to the team the request for better error messaging. This is still not enough to determine why you are hitting an issue as nothing here is jumping out as a problem. If you can include the full config and logs that may help or reach out to support to be able to provide that via our ticketing system. @nikhil-mongo can you respond if more information comes in?