terraform-provider-mongodbatlas: Error: error creating MongoDB Cluster: unexpected EOF

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.0.5
+ provider registry.terraform.io/mongodb/mongodbatlas v0.9.1

(also occurs under mongodbatlas v1.2.0)

Terraform Configuration File


resource "mongodbatlas_project" "project" {
  name   = data.google_project.project.name
  org_id = [REDACTED]
}

resource "mongodbatlas_network_peering" "test" {
  project_id     = mongodbatlas_project.project.id
  container_id   = mongodbatlas_cluster.cluster.container_id
  provider_name  = "GCP"
  gcp_project_id = data.google_project.project.id
  network_name   = "default"
}

resource "mongodbatlas_cluster" "cluster" {
  project_id   = mongodbatlas_project.project.id
  name         = data.google_project.project.name
  cluster_type = "REPLICASET"
  replication_specs {
    num_shards = 1
    regions_config {
      region_name     = "EUROPE_WEST_2"
      electable_nodes = 3
      priority        = 7
      read_only_nodes = 0
    }
  }
  provider_backup_enabled                         = true
  auto_scaling_disk_gb_enabled                    = true
  mongo_db_major_version                          = "5.0"
  auto_scaling_compute_enabled                    = true
  provider_auto_scaling_compute_min_instance_size = "M10"
  provider_auto_scaling_compute_max_instance_size = "M30"
  auto_scaling_compute_scale_down_enabled         = true

  lifecycle {
    ignore_changes = [provider_instance_size_name]
  }

  //Provider Settings "block"
  provider_name               = "GCP"
  disk_size_gb                = 10
  provider_instance_size_name = "M10"
}

resource "time_sleep" "wait_for_mongo_private_connection_string" {
  depends_on      = [mongodbatlas_network_peering.test, google_compute_network_peering.peering]
  create_duration = "300s"
}

data "mongodbatlas_cluster" "cluster" {
  depends_on = [time_sleep.wait_for_mongo_private_connection_string]
  project_id = mongodbatlas_cluster.cluster.project_id
  name       = mongodbatlas_cluster.cluster.name
}

resource "mongodbatlas_database_user" "mongo_user" {
  username           = random_string.mongo_user_username.result
  password           = random_password.mongo_user_password.result
  project_id         = mongodbatlas_cluster.cluster.project_id
  auth_database_name = "admin"

  roles {
    role_name     = "readWrite"
    database_name = [REDACTED]
  }
}

data "mongodbatlas_cluster" "database" {
  project_id = mongodbatlas_cluster.cluster.project_id
  name       = mongodbatlas_cluster.cluster.name
}

resource "mongodbatlas_project_ip_access_list" "access" {
  project_id = mongodbatlas_cluster.cluster.project_id
  cidr_block = [REDACTED]
  comment    = [REDACTED]
}

data "mongodbatlas_project_ip_access_list" "access" {
  project_id = mongodbatlas_project_ip_access_list.access.project_id
  cidr_block = mongodbatlas_project_ip_access_list.access.cidr_block
}

Steps to Reproduce

  1. terraform init
  2. terraform apply

Expected Behavior

It should create the cluster without erroring

Actual Behavior

terraform apply failed with an error (see below)

Debug Output

terraform.log

Running with TF_LOG=debug

2022-02-10T11:29:35.994Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: -----------------------------------------------------
2022-02-10T11:29:35.994Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: 2022/02/10 11:29:35 [DEBUG] status for MongoDB cluster: dashboard-counts: CREATING
2022-02-10T11:29:35.994Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: 2022/02/10 11:29:35 [TRACE] Waiting 1m0s before next try
2022-02-10T11:30:35.994Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: 2022/02/10 11:30:35 [DEBUG] MongoDB Atlas API Request Details:
2022-02-10T11:30:35.994Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: ---[ REQUEST ]---------------------------------------
2022-02-10T11:30:35.994Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: GET /api/atlas/v1.0/groups/[REDACTED]/clusters/[REDACTED] HTTP/1.1
2022-02-10T11:30:35.994Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: Host: cloud.mongodb.com
2022-02-10T11:30:35.994Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: User-Agent: terraform-provider-mongodbatlas/devel
2022-02-10T11:30:35.994Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: Accept: application/json
2022-02-10T11:30:35.995Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: Accept-Encoding: gzip
2022-02-10T11:30:35.995Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: 
2022-02-10T11:30:35.995Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: 
2022-02-10T11:30:35.995Z [DEBUG] provider.terraform-provider-mongodbatlas_v0.9.1: -----------------------------------------------------
2022-02-10T11:30:36.499Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2022-02-10T11:30:36.499Z [DEBUG] provider.terraform-provider-google_v4.10.0_x5: 2022/02/10 11:30:36 [DEBUG] [transport] transport: http2Server.HandleStreams failed to read frame: read unix /var/folders/7f/w84b0r3d3db30p472087v9zc0000gn/T/plugin229942681->: use of closed network connection 
2022-02-10T11:30:36.499Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2022-02-10T11:30:36.499Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2022-02-10T11:30:36.500Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2022-02-10T11:30:36.502Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/null/3.1.0/darwin_amd64/terraform-provider-null_v3.1.0_x5 pid=74467
2022-02-10T11:30:36.502Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/time/0.7.2/darwin_amd64/terraform-provider-time_v0.7.2_x5 pid=74473
2022-02-10T11:30:36.502Z [DEBUG] provider: plugin exited
2022-02-10T11:30:36.502Z [DEBUG] provider: plugin exited
2022-02-10T11:30:36.503Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/0.9.1/darwin_amd64/terraform-provider-mongodbatlas_v0.9.1 pid=74469
2022-02-10T11:30:36.503Z [DEBUG] provider: plugin exited
2022-02-10T11:30:36.545Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/google/4.10.0/darwin_amd64/terraform-provider-google_v4.10.0_x5 pid=74474
2022-02-10T11:30:36.545Z [DEBUG] provider: plugin exited

Console output

mongodbatlas_cluster.cluster: Still creating... [9m10s elapsed]
mongodbatlas_cluster.cluster: Still creating... [9m20s elapsed]
mongodbatlas_cluster.cluster: Still creating... [9m30s elapsed]
mongodbatlas_cluster.cluster: Still creating... [9m40s elapsed]
mongodbatlas_cluster.cluster: Still creating... [9m50s elapsed]
╷
│ Error: error creating MongoDB Cluster: Get "https://cloud.mongodb.com/api/atlas/v1.0/groups/[REDACTED]/clusters/[REDACTED]": unexpected EOF
│ 
│   with mongodbatlas_cluster.cluster,
│   on main.tf line 1054, in resource "mongodbatlas_cluster" "cluster":
│ 1054: resource "mongodbatlas_cluster" "cluster" {
│ 
╵

Additional Context

This is running on GCP

References

Initially mentioned on: https://github.com/mongodb/terraform-provider-mongodbatlas/issues/110

Fwiw the workaround is to use https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/cluster#import and then run terraform apply again.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (1 by maintainers)

Most upvoted comments

@adam-pasabi just put the logs here so @martinstibbe can see them.

Internal ticket INTMDB-304

@adam-pasabi We are reviewing it and will get back to you on this soon.