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
242 stars 168 forks source link

Invalid AWS region error in mongodbatlas_serverless_instance #882

Closed Xenon130 closed 2 years ago

Xenon130 commented 2 years ago

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.3.3
on windows_amd64
+ provider registry.terraform.io/hashicorp/aws v3.75.2
+ provider registry.terraform.io/mongodb/mongodbatlas v1.4.6

Terraform Configuration File

provider "mongodbatlas" {
  public_key  = "<API-KEY>"
  private_key = "<API-KEY-PRIVATE>"
}
resource "mongodbatlas_project" "test" {
  name   = "test"
  org_id = "<ORG-ID>"

  is_collect_database_specifics_statistics_enabled = true
  is_data_explorer_enabled                         = true
  is_performance_advisor_enabled                   = true
  is_realtime_performance_panel_enabled            = true
  is_schema_advisor_enabled                        = true
}
resource "mongodbatlas_serverless_instance" "test-db" {
  project_id = mongodbatlas_project.test.id
  name       = "test-db"

  provider_settings_backing_provider_name = "AWS"
  provider_settings_provider_name         = "SERVERLESS"
  provider_settings_region_name           = "us-west-2"
}

Steps to Reproduce

  1. terraform init
  2. terraform apply

Expected Behavior

Should create db instance in specified region.

Actual Behavior

Throws error stating no such region on AWS.

Crash Output

mongodbatlas_serverless_instance.quantum-db: Creating...
╷
│ Error: error creating serverless instance: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/[xxx]/serverless: 
400 (request "INVALID_REGION") No region us-west-2 exists for provider AWS.
│
│   with mongodbatlas_serverless_instance.test-db,
│   on ec2_flight.tf line 136, in resource "mongodbatlas_serverless_instance" "test-db":
│  136: resource "mongodbatlas_serverless_instance" "test-db" {
│
╵
martinstibbe commented 2 years ago

@Xenon130 If you use US_WEST_2 in place of us-west-2 it should work

provider_settings_region_name = "US_WEST_2" // "us-west-2"

Xenon130 commented 2 years ago

I'm passing it as a variable, but that worked:

provider_settings_region_name = replace(upper(local.aws_region),"-","_")

Thanks!