Skip to content

Terraform crash when using bloc moved from mongodbatlas_cluster to mongodbatlas_advanced_cluster #37710

@zenzedoon

Description

@zenzedoon

Terraform Version

Terraform v1.12.0
on linux_amd64
+ provider registry.terraform.io/hashicorp/random v3.7.2
+ provider registry.terraform.io/mastercard/restapi v2.0.1
+ provider registry.terraform.io/mongodb/mongodbatlas v2.0.1

Your version of Terraform is out of date! The latest version
is 1.13.3. You can update by downloading from https://developer.hashicorp.com/terraform/install

Terraform Configuration Files

terraform {
  required_providers {
    mongodbatlas = {
      source  = "mongodb/mongodbatlas"
      version = "~> 2.0.0"
    }
  }
  required_version = ">= 1.12"
}
moved {
  from = mongodbatlas_cluster.cluster
  to   = mongodbatlas_advanced_cluster.cluster
}
resource "mongodbatlas_advanced_cluster" "cluster" {
  project_id             = var.project_id
  name                   = var.cluster_name
  mongo_db_major_version = var.mongo_db_major_version
  cluster_type           = var.cluster_type

  backup_enabled = var.cloud_backup

  termination_protection_enabled = var.termination_protection_enabled

  replication_specs = [{
    num_shards    = var.num_shards
    region_configs = [{
      region_name   = var.provider_region_name
      provider_name = var.provider_name
    

      priority      = var.priority
    
      electable_specs = {
        instance_size = var.provider_instance_size_name
        node_count    = var.electable_nodes
      }
    
      read_only_specs = var.read_only_nodes > 0 ? {
        instance_size = var.provider_instance_size_name
        node_count    = var.read_only_nodes
      } : null
    
      analytics_specs = var.analytics_nodes > 0 ? {
        instance_size = var.provider_instance_size_name
        node_count    = var.analytics_nodes
      } : null
    
      auto_scaling = {
        disk_gb_enabled            = var.auto_scaling_disk_gb_enabled
        compute_enabled            = var.auto_scaling_compute_enabled
        compute_scale_down_enabled = var.auto_scaling_compute_enabled ? var.auto_scaling_compute_scale_down_enabled : null
        compute_min_instance_size  = var.auto_scaling_compute_enabled ? var.provider_auto_scaling_compute_min_instance_size : null
        compute_max_instance_size  = var.auto_scaling_compute_enabled ? var.provider_auto_scaling_compute_max_instance_size : null
      }
    }]
  }]

  bi_connector_config = {
    enabled         = var.bi_connector_enabled
    read_preference = var.bi_connector_read_preference
  }


  advanced_configuration = {
    javascript_enabled                   = var.javascript_enabled
    minimum_enabled_tls_protocol         = "TLS1_2"
    sample_size_bi_connector             = var.bi_connector_enabled ? var.sample_size_bi_connector : null
    sample_refresh_interval_bi_connector = var.bi_connector_enabled ? var.sample_refresh_interval_bi_connector : null
  }


  labels = local.tags 


  pinned_fcv = var.pinned_upgrade_enabled ? {
    expiration_date = var.pinned_fcv_expiration_date
  } : null
}

...terraform config...

Debug Output

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

panic: interface conversion: interface {} is float64, not string
goroutine 51 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:26 +0x5e
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        github.com/hashicorp/terraform/internal/logging/panic.go:84 +0x16a
panic({0x33926a0?, 0xc001605da0?})
        runtime/panic.go:792 +0x132
github.com/hashicorp/terraform/internal/command/jsonformat/structured/attribute_path.(*PathMatcher).GetChildWithKey(0xc0008ef9e0, {0xc000d57cb0, 0xb})
        github.com/hashicorp/terraform/internal/command/jsonformat/structured/attribute_path/matcher.go:154 +0x2ec
github.com/hashicorp/terraform/internal/command/jsonformat/structured.ChangeMap.GetChild({0x0, 0xc0013edf50, 0x0, 0x0, 0xc0016043c0, {0x4067d48, 0xc0008ef9c0}, {0x4067d48, 0xc0008ef9e0}, 0x1}, ...)
        github.com/hashicorp/terraform/internal/command/jsonformat/structured/map.go:76 +0x39b
github.com/hashicorp/terraform/internal/command/jsonformat/differ.processObject[...]({0x0, 0x0, {0x0, 0x0}, {0x3410f20, 0xc0013edf50}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...)
        github.com/hashicorp/terraform/internal/command/jsonformat/differ/object.go:62 +0x1dc
github.com/hashicorp/terraform/internal/command/jsonformat/differ.computeAttributeDiffAsNestedObject({0x0, 0x0, {0x0, 0x0}, {0x3410f20, 0xc0013edf50}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...)
        github.com/hashicorp/terraform/internal/command/jsonformat/differ/object.go:36 +0x296
github.com/hashicorp/terraform/internal/command/jsonformat/differ.computeDiffForNestedAttribute({0x0, 0x0, {0x0, 0x0}, {0x3410f20, 0xc0013edf50}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...)
        github.com/hashicorp/terraform/internal/command/jsonformat/differ/attribute.go:38 +0x205
github.com/hashicorp/terraform/internal/command/jsonformat/differ.ComputeDiffForAttribute({0x0, 0x0, {0x0, 0x0}, {0x3410f20, 0xc0013edf50}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...)
        github.com/hashicorp/terraform/internal/command/jsonformat/differ/attribute.go:21 +0x45
github.com/hashicorp/terraform/internal/command/jsonformat/differ.ComputeDiffForBlock({0x0, 0x0, {0x3410f20, 0xc0013ede00}, {0x3410f20, 0xc0013edec0}, {0x3410f20, 0xc001604210}, {0x3410f20, 0xc0016042a0}, ...}, ...)
        github.com/hashicorp/terraform/internal/command/jsonformat/differ/block.go:49 +0x468
github.com/hashicorp/terraform/internal/command/jsonformat.precomputeDiffs({{0x392d926, 0x3}, 0xc000828b10, {0xc0001d1508, 0x11, 0x20}, {0xc000cc1608, 0x5, 0x8}, {0xc00067cb08, ...}, ...}, ...)
        github.com/hashicorp/terraform/internal/command/jsonformat/diff.go:52 +0x345
github.com/hashicorp/terraform/internal/command/jsonformat.Plan.renderHuman({{0x392d926, 0x3}, 0xc000828b10, {0xc0001d1508, 0x11, 0x20}, {0xc000cc1608, 0x5, 0x8}, {0xc00067cb08, ...}, ...}, ...)
        github.com/hashicorp/terraform/internal/command/jsonformat/plan.go:60 +0x85
github.com/hashicorp/terraform/internal/command/jsonformat.Renderer.RenderHumanPlan({0xc000876d50?, 0xc0003316b0?, 0x89?}, {{0x392d926, 0x3}, 0xc000828b10, {0xc0001d1508, 0x11, 0x20}, {0xc000cc1608, ...}, ...}, ...)
        github.com/hashicorp/terraform/internal/command/jsonformat/renderer.go:122 +0x1cf
github.com/hashicorp/terraform/internal/command/views.(*OperationHuman).Plan(0xc0007bba50, 0xc000ea31e0, 0xc001d9c900)
        github.com/hashicorp/terraform/internal/command/views/operation.go:130 +0x2fc
github.com/hashicorp/terraform/internal/backend/local.(*Local).opPlan(0xc000b22a00, {0x4066690, 0xc0005fb810}, {0x4066690, 0xc0005fb860}, 0xc0001d8f00, 0xc000bc4640)
        github.com/hashicorp/terraform/internal/backend/local/backend_plan.go:204 +0xe35
github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation.func1()
        github.com/hashicorp/terraform/internal/backend/local/backend.go:339 +0xb8
created by github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation in goroutine 1
        github.com/hashicorp/terraform/internal/backend/local/backend.go:332 +0x3fa

Expected Behavior

execute the bloc move seccessfully

Actual Behavior

terraform crash and dont migrate the old ressource to the new one .

Steps to Reproduce

terraform plan --var-file=variables.tfvars

Additional Context

No response

References

No response

Generative AI / LLM assisted development?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugduplicateissue closed because another issue already tracks this problemnewnew issue not yet triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions