MongoDB Atlas Provider - Terraform

Viewed 350

I am not able to figure out below in Terraform (>= 0.13) using MongoDB Atlas provider (version >= 0.9.1)

How to set below 2 properties. Did a lot of google search with no luck

As per the documentation here: https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/cluster

I would like to set below 2 properties:

providerSettings.autoScaling.compute.maxInstanceSize
providerSettings.autoScaling.compute.minInstanceSize

I have not tried above keys as it has . in it

tried below with no luck

  providerAutoScalingComputeMaxInstanceSize = "M20"
  providerAutoScalingComputeMinInstanceSize = "M10"
  provider_autoScaling_compute_maxInstanceSize = "M20"
  provider_autoScaling_compute_minInstanceSize = "M10"

On terraform plan. I see error:


Error: Unsupported argument

  on .terraform/modules/mongodb_test_b/main.tf line 10, in resource "mongodbatlas_cluster" "mongodbatlas_cluster":
  10:   providerAutoScalingComputeMaxInstanceSize = var.providerAutoScalingComputeMaxInstanceSize

An argument named "providerAutoScalingComputeMaxInstanceSize" is not expected
here.


Error: Unsupported argument

  on .terraform/modules/mongodb_test_b/main.tf line 12, in resource "mongodbatlas_cluster" "mongodbatlas_cluster":
  12:   providerAutoScalingComputeMinInstanceSize = var.providerAutoScalingComputeMinInstanceSize

An argument named "providerAutoScalingComputeMinInstanceSize" is not expected
here.


Code snippet

resource "mongodbatlas_cluster" "mongodbatlas_cluster" {
  project_id          = var.project_id
  provider_name       = var.provider_name
  name                = var.name
  provider_instance_size_name   = var.provider_instance_size_name
  provider_disk_type_name       = var.provider_disk_type_name
  auto_scaling_compute_enabled  = var.auto_scaling_compute_enabled
  providerAutoScalingComputeMaxInstanceSize = var.providerAutoScalingComputeMaxInstanceSize
  auto_scaling_compute_scale_down_enabled = var.auto_scaling_compute_scale_down_enabled
  providerAutoScalingComputeMinInstanceSize = var.providerAutoScalingComputeMinInstanceSize
  pit_enabled                   = var.pit_enabled
  cluster_type                  = var.cluster_type
  replication_specs {
    num_shards = var.replication_specs_num_shards
    regions_config {
      region_name     = var.region_name
      electable_nodes = var.replication_specs_regions_config_electable_nodes
      priority        = var.replication_specs_regions_config_priority
      read_only_nodes = var.replication_specs_regions_config_read_only_nodes
      analytics_nodes = var.analytics_nodes
    }
  }
  mongo_db_major_version        = var.mongo_db_major_version
  provider_backup_enabled       = var.provider_backup_enabled
  auto_scaling_disk_gb_enabled  = var.auto_scaling_disk_gb_enabled

}

Any assistance. Much appreciated.

1 Answers

You are using the wrong argument names, you need these two:

  1. provider_auto_scaling_compute_min_instance_size [1]
  2. provider_auto_scaling_compute_max_instance_size [2]

Your code should look like this:

  provider_auto_scaling_compute_max_instance_size = var.providerAutoScalingComputeMaxInstanceSize
  provider_auto_scaling_compute_min_instance_size = var.providerAutoScalingComputeMinInstanceSize

You might also consider naming your variables differently, i.e., using the same names for those as for the argument names as that helps with mapping between what an argument is and what value will it have.

[1] https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/cluster#provider_auto_scaling_compute_min_instance_size

[2] https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/cluster#provider_auto_scaling_compute_max_instance_size

Related