akshaykarle / terraform-provider-mongodbatlas

Terraform provider for MongoDB Atlas
Mozilla Public License 2.0
122 stars 54 forks source link

An invalid enumeration value M0 was specified. #117

Closed 67726e closed 1 month ago

67726e commented 1 month ago

I am unable to create an cluster with the M0 free tier.

╷
│ Error: error creating advanced cluster: https://cloud.mongodb.com/api/atlas/v2/groups/66b8f12fd04e950940cebf87/clusters POST: HTTP 400 Bad Request (Error code: "INVALID_ENUM_VALUE") Detail: An invalid enumeration value M0 was specified. Reason: Bad Request. Params: [M0]
│ 
│   with mongodbatlas_advanced_cluster.cluster,
│   on cluster.tf line 2, in resource "mongodbatlas_advanced_cluster" "cluster":
│    2: resource "mongodbatlas_advanced_cluster" "cluster" {
│ 
╵
resource "mongodbatlas_advanced_cluster" "cluster" {
    project_id = mongodbatlas_project.project.id
    name = "cluster-test"
    cluster_type = "REPLICASET"
    backup_enabled = false
    termination_protection_enabled = false

    # Note: This is always the version for `M0`
    mongo_db_major_version = "4.4"
    version_release_system = "LTS"

    replication_specs {
        region_configs {
            priority = 1
            provider_name = "AWS"
            region_name = "US_EAST_1"

            electable_specs {
                instance_size = "M0"
                node_count = 1
            }
        }
    }
}
67726e commented 1 month ago

For the hell of it, I tried switching M0 to M2 and received the same error. However, setting the configuration to M10 brought out a new error:

╷
│ Error: error creating advanced cluster: https://cloud.mongodb.com/api/atlas/v2/groups/66b8f12fd04e950940cebf87/clusters POST: HTTP 400 Bad Request (Error code: "REPLICATION_SPECS_REQUIRES_ELECTABLE_SPECS") Detail: A replication spec requires at least three electable nodes. Reason: Bad Request. Params: []
│ 
│   with mongodbatlas_advanced_cluster.cluster,
│   on cluster.tf line 2, in resource "mongodbatlas_advanced_cluster" "cluster":
│    2: resource "mongodbatlas_advanced_cluster" "cluster" {
│ 
╵

Guessing I'm running configuration from the examples that are meant for a proper server that don't apply to the lesser tiers?

SpencerBrown commented 1 month ago

from the README here:


IMPORTANT NOTE - This provider is no longer under development. Please use the official, verified Terraform MongoDB Atlas Provider: -Documentation -GitHub Repo

To receive support for the MongoDB Atlas Terraform Provider, if you have a paid support option for your Atlas deployment, you can open a support case. If not, you can use the support chat option.

67726e commented 1 month ago

Whoops! Not sure how I ended up on this repository, thank you for letting me know!

67726e commented 1 month ago

In case SEO leads future developers here, the issue lies with some unfortunate sleight-of-hand in the current (as of August 2024) documentation on the Terraform resources page(s). The documentation for mongodbatlas_cluster has a prominent alert at the start of the page telling users that they should use mongodbatlas_advanced_cluster for new clusters. However, the mongodbatlas_advanced_cluster page neglects to mention that it apparently does not support anything less than M10, which is not actually documented but gleaned from other GitHub Issue comments. Further down on the original mongodbatlas_cluster there is documentation confirming that M0, M2, and M5 are, in fact, supported.

Here is an example of a minimal M0 cluster created via Terraform that is working for me as of this comment:

resource "mongodbatlas_cluster" "cluster" {
    project_id = mongodbatlas_project.project.id
    name = "cluster-test"
    cluster_type = "REPLICASET"

    cloud_backup = false
    auto_scaling_compute_enabled = false
    auto_scaling_disk_gb_enabled = false
    mongo_db_major_version = "7.0"

    backing_provider_name = "AWS"
    provider_instance_size_name = "M0"
    provider_name = "TENANT"
    provider_region_name = "US_EAST_1"

    replication_specs {
        num_shards = 1

        regions_config {
            region_name = "US_EAST_1"

            electable_nodes = 3
            priority = 7
            read_only_nodes = 0
        }
    }
}