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

mongoatlas_cluster fails to create - invalid enumeration value M2 was specified #160

Closed StewartSnow closed 4 years ago

StewartSnow commented 4 years ago

Hi, We're having a problem deploying a simple M2 cluster with the following configuration. We get the error:

mongodbatlas_cluster.atlas_cluster: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/
5e5e3a35d474757c8d98b41d/clusters: 400 (request "Bad Request") An invalid enumeration value M2 was specified.

We're using 0.4.1 version of the provider and terraform v0.12.21

resource "mongodbatlas_cluster" "atlas_cluster" {
  project_id   = "${mongodbatlas_project.atlas_project.id}"
  name         = "${var.project}-cluster"
  num_shards   = 1
  backup_enabled = true

  replication_factor           = 3 // default
  mongo_db_major_version       = "4.2"
  cluster_type                 = "REPLICASET"

  // Provider Settings "block"
  provider_name               = "AWS"
  disk_size_gb                = 100 # this is the minimum & default
  provider_volume_type        = "STANDARD"
  provider_region_name        = "US_EAST_1"
  provider_instance_size_name = "M2" 
}

We've been through everything that we can think of, but can't figure it out, any advice??

StewartSnow commented 4 years ago

Resolved - for others similarly confused. The solution was as follows:

The documentation mentions somewhere that the TENANT type (which is for multi-tenant usage), is also necessary (seems rather confusing to us), that specifically for M2 and M5 instance sizes, you need to use this value instead of a provider name, and then specify the target provider using the backing_provider_name property....

This is all down to the mongo atlas api behaviour, not the terraform provider

backing_provider_name       = "AWS"
  provider_name               = "TENANT" // this is a real gotcha - needs to be TENANT for M2 & M5 instances....
  disk_size_gb                = 100      # this is the minimum & default
  provider_region_name        = "US_EAST_1"
  provider_instance_size_name = "M2"
themantissa commented 4 years ago

@StewartSnow did want to let you know we added a shared/multi-tenant example in the clusters doc to help. https://www.terraform.io/docs/providers/mongodbatlas/r/cluster.html#example-aws-shared-tier-cluster. Appreciated your submitting how it can be confusing.