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

Project deletion being attempted before cluster is destroyed #724

Closed dikirahman closed 2 years ago

dikirahman commented 2 years ago

Terraform CLI and Terraform MongoDB Atlas Provider Version

❯ terraform version
Terraform v1.1.9
on darwin_arm64

Terraform Configuration File

resource "mongodbatlas_cluster" "cluster" {
  project_id                  = mongodbatlas_project.project.id
  name                        = var.cluster_name
  mongo_db_major_version      = var.mongodbversion
  cluster_type                = var.cluster_type
  provider_name               = var.provider_name
  backing_provider_name       = var.cloud_provider
  provider_region_name        = var.provider_region
  provider_instance_size_name = var.provider_instance_size_name
}

resource "mongodbatlas_database_user" "user" {
  username           = var.dbuser
  password           = var.dbuser_password
  project_id         = mongodbatlas_project.project.id
  auth_database_name = var.auth_database_name

  roles {
    role_name     = "readWrite"
    database_name = var.database_name
  }

  roles {
    role_name     = "atlasAdmin"
    database_name = var.roles_database_name
  }

  labels {
    key   = "Name"
    value = "DB User1"
  }
}

resource "mongodbatlas_project_ip_access_list" "ip" {
  project_id = mongodbatlas_project.project.id
  cidr_block = var.ip_address
  comment    = "IP Address for accessing the cluster"
}

resource "mongodbatlas_project" "project" {
  name   = var.project_name
  org_id = var.atlas_org_id
}

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. terraform destroy

Expected Behavior

it should destroy projects, clusters and databases, but sometimes it successful to destroy and sometimes fails to destroy.

Actual Behavior

mongodb
themantissa commented 2 years ago

@dikirahman what provider version are you using. Also going to update the issue subject to better capture what you are reporting.

dikirahman commented 2 years ago

@themantissa I'm using version 1.3.0

themantissa commented 2 years ago

Internal ticket INTMDB-332

martinstibbe commented 2 years ago

@dikirahman This was fixed in v1.3.2 based on this enhancement to project resource INTMDB-302: Ensure we handle new flow for project deletion well by @evertsd in https://github.com/mongodb/terraform-provider-mongodbatlas/pull/688 could you try a newer version of provider to validate

dikirahman commented 2 years ago

@martinstibbe Thanks for the update however I get the following error when running terraform init -upgrade

image
dikirahman commented 2 years ago

We decided to use version v1.4.3 and it works