hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
609 stars 449 forks source link

vsphere_compute_cluster_vm_group still contains unknown values during apply #1984

Open cello86 opened 11 months ago

cello86 commented 11 months ago

Community Guidelines

Terraform

v1.3.9

Terraform Provider

v2.2.0

VMware vSphere

v7.0.3

Description

I tried to create a cluster vm group on vpshere but I received this error.

β”‚ configuration for vsphere_compute_cluster_vm_group.kong_proxy_cluster_vm_group_dc2 still contains unknown values during apply (this is a bug in Terraform; please report it!)
β”‚ The following paths in the resource configuration are unknown:
β”‚ cty.Path{cty.GetAttrStep{Name:"virtual_machine_ids"}, cty.IndexStep{Key:cty.UnknownVal(cty.String)}}

Affected Resources or Data Sources

vsphere_compute_cluster_vm_group

Terraform Configuration

esource "vsphere_compute_cluster_vm_group" "kong_proxy_cluster_vm_group_dc1" {
  name                = var.vm_kong_proxy_dc1_vm_group_name
  compute_cluster_id  = data.vsphere_compute_cluster.kong_proxy_cluster.id
  virtual_machine_ids = local.kong_proxy_dc1_vm_ids
}

resource "vsphere_compute_cluster_vm_group" "kong_proxy_cluster_vm_group_dc2" {
  name                = var.vm_kong_proxy_dc2_vm_group_name
  compute_cluster_id  = data.vsphere_compute_cluster.kong_proxy_cluster.id
  virtual_machine_ids = local.kong_proxy_dc2_vm_ids
}

resource "vsphere_compute_cluster_vm_group" "kong_admin_cluster_vm_group_dc1" {
  name                = var.vm_kong_admin_dc1_vm_group_name
  compute_cluster_id  = data.vsphere_compute_cluster.kong_admin_cluster.id
  virtual_machine_ids = local.kong_admin_dc1_vm_ids
}

resource "vsphere_compute_cluster_vm_group" "kong_admin_cluster_vm_group_dc2" {
  name                = var.vm_kong_admin_dc2_vm_group_name
  compute_cluster_id  = data.vsphere_compute_cluster.kong_admin_cluster.id
  virtual_machine_ids = local.kong_admin_dc2_vm_ids
}

resource "vsphere_compute_cluster_vm_host_rule" "kong_proxy_cluster_vm_affinity_rule_dc1" {
  compute_cluster_id       = data.vsphere_compute_cluster.kong_proxy_cluster.id
  name                     = var.vm_kong_proxy_dc1_affinity_rule
  vm_group_name            = vsphere_compute_cluster_vm_group.kong_proxy_cluster_vm_group_dc1.name
  affinity_host_group_name = data.vsphere_compute_cluster_host_group.kong_proxy_dc1_host_group.name
  enabled                  = true
  mandatory                = true
}
resource "vsphere_compute_cluster_vm_host_rule" "kong_proxy_cluster_vm_affinity_rule_dc2" {
  compute_cluster_id       = data.vsphere_compute_cluster.kong_proxy_cluster.id
  name                     = var.vm_kong_proxy_dc2_affinity_rule
  vm_group_name            = vsphere_compute_cluster_vm_group.kong_proxy_cluster_vm_group_dc2.name
  affinity_host_group_name = data.vsphere_compute_cluster_host_group.kong_proxy_dc2_host_group.name
  enabled                  = true
  mandatory                = true
}

resource "vsphere_compute_cluster_vm_host_rule" "kong_admin_cluster_vm_affinity_rule_dc1" {
  compute_cluster_id       = data.vsphere_compute_cluster.kong_admin_cluster.id
  name                     = var.vm_kong_admin_dc1_affinity_rule
  vm_group_name            = vsphere_compute_cluster_vm_group.kong_admin_cluster_vm_group_dc1.name
  affinity_host_group_name = data.vsphere_compute_cluster_host_group.kong_admin_dc1_host_group.name
  enabled                  = true
  mandatory                = true
}

Debug Output

no debug info

Panic Output

No response

Expected Behavior

cluster vm group must to be created

Actual Behavior

no cluster vm group has been created

Steps to Reproduce

I run terraform

Environment Details

No response

Screenshots

No response

References

No response

github-actions[bot] commented 11 months ago

Hello, cello86! πŸ–

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

tenthirtyam commented 11 months ago
cello86 commented 11 months ago

Hi @tenthirtyam

  1. I updated the provider and terraform to latest versions
  2. I tried the reapply with the same issue.
#  terraform apply -target=vsphere_compute_cluster_vm_group.kong_proxy_cluster_vm_group_dc1 -target=vsphere_compute_cluster_vm_host_rule.kong_proxy_cluster_vm_affinity_rule_dc1 -target=vsphere_virtual_machine.kong_proxy_dc1[1]
...
Terraform will perform the following actions:

  # vsphere_compute_cluster_vm_group.kong_proxy_cluster_vm_group_dc1 will be created
  + resource "vsphere_compute_cluster_vm_group" "kong_proxy_cluster_vm_group_dc1" {
      + compute_cluster_id  = "domain-xxx"
      + id                  = (known after apply)
      + name                = "pr_prod_apisitepublicproxy_vm"
      + virtual_machine_ids = (known after apply)
    }

  # vsphere_compute_cluster_vm_host_rule.kong_proxy_cluster_vm_affinity_rule_dc1 will be created
  + resource "vsphere_compute_cluster_vm_host_rule" "kong_proxy_cluster_vm_affinity_rule_dc1" {
      + affinity_host_group_name = "xxx"
      + compute_cluster_id       = "domain-xxx"
      + enabled                  = true
      + id                       = (known after apply)
      + mandatory                = true
      + name                     = "pr_prod_apisitepublicproxy_affinity"
      + vm_group_name            = "pr_prod_apisitepublicproxy_vm"
    }

Plan: 2 to add, 0 to change, 0 to destroy.

vsphere_compute_cluster_vm_group.kong_proxy_cluster_vm_group_dc1: Creating...
β•·
β”‚ Error: Configuration contains unknown value
β”‚
β”‚ configuration for vsphere_compute_cluster_vm_group.kong_proxy_cluster_vm_group_dc1 still contains unknown values during apply (this is a bug in Terraform; please report it!)
β”‚ The following paths in the resource configuration are unknown:
β”‚ cty.Path{cty.GetAttrStep{Name:"virtual_machine_ids"}, cty.IndexStep{Key:cty.UnknownVal(cty.String)}}
  1. I have already the same value on the created resource vsphere_virtual_machine
    $ terraform state show vsphere_virtual_machine.kong_proxy_dc1[1] | grep id
    ...
    id                                      = "4200dd97-12c3-ef09-9a78-cffddcd81214"

Could it be the problem related to the target option?

Thanks, Marcello