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

mongodbatlas_cluster fails to redeploy manually deleted cluster #159

Closed emanuelmuraru closed 4 years ago

emanuelmuraru commented 4 years ago

Description

Terraform will not redeploy a manually deleted Mongodb Cluster even though it is refreshing the state. However it manages to restore a manually altered cluster (if I, say, enable the backup in the atlas portal, terraform changes it back on the next apply).

Expected behavior

terraform apply will refresh the state and deploy a new cluster.

Actual behavior

No action is taken after state refresh.

terraform plan will output something like

mongodbatlas_cluster.cluster: Refreshing state... [id=...]

------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.

Configuration

Terraform version: 0.12.2 Provider version: 0.4.1

resource "mongodbatlas_cluster" "cluster" {
    project_id = var.project_id
    name     = "${local.region_based_name}-mongoatlas"
    num_shards   = var.num_shards

    cluster_type = var.cluster_type
    replication_factor           = var.replication_factor
    backup_enabled               = var.backup_enabled
    auto_scaling_disk_gb_enabled = var.auto_scaling_disk_gb
    mongo_db_major_version       = var.mongo_db_major_version

    provider_name               = var.provider_name 
    provider_instance_size_name = var.instance_size
    provider_region_name        = var.region_name

    advanced_configuration = {
      fail_index_key_too_long = false
      javascript_enabled = false
      minimum_enabled_tls_protocol         = "TLS1_2"
      no_table_scan = false
      oplog_size_mb = ""
      sample_refresh_interval_bi_connector = 0
      sample_size_bi_connector = 0
 }

    depends_on = [mongodbatlas_network_peering.network_peering]
}
themantissa commented 4 years ago

@emanuelmuraru thank you for the information and report. We'll take a look and see what's going on.

themantissa commented 4 years ago

Confirmed, deleting manually refresh does not pick up change. When trying to then destroy via terraform it causes an error.