terraform-provider-nutanix icon indicating copy to clipboard operation
terraform-provider-nutanix copied to clipboard

Bug: Using project_reference causes plans to fail with "additonal reasources was unexpected".

Open FruityWelsh opened this issue 3 years ago • 2 comments

Nutanix Cluster Information

"api_version": "3.1"

Terraform Version

Terraform v0.15.0

  • provider registry.terraform.io/nutanix/nutanix v1.2.0

Affected Resource(s)

  • nutanix_XXXXX

Terraform Configuration Files

main.tf:

terraform {
  required_providers {
    nutanix = {
      source = "nutanix/nutanix"
      version = "~> 1.2"
    }
  }
}

data "nutanix_clusters" "clusters" {}
resource "nutanix_virtual_machine" "vm1" {
  name = var.vm_name
  cluster_uuid = data.nutanix_clusters.clusters.entities.0.metadata.uuid
  #cluster_uuid = var.cluster_uuid
  num_vcpus_per_socket = 1
  num_sockets          = 2
  memory_size_mib      = 2048

  project_reference = {
    kind = "project"
    uuid = var.project_uuid
    }

Debug Output

Expected Behavior

That project_reference would allow for adding vm to specific project

Actual Behavior

Fails with project reference being unknown

Steps to Reproduce

Run this code in both vcs mode on terraform enterprise, or cli mode on terraform enterprise.

Important Factors

This error only occurs in prism element and not prism central.

  • #0000 <!---Github Issue number --->

FruityWelsh avatar Apr 20 '21 13:04 FruityWelsh

Hi,

Can you try to pass both the uuid and project name?

   project_reference = {
     kind = "project"
     name = "my_project_name"
     uuid = "my_project_uuid"
   }

yannickstruyf3 avatar May 18 '21 09:05 yannickstruyf3

Any update on this issue?

Currently failing with the following error: Error: Unsupported block type │ │ on main.tf line 239, in resource "nutanix_virtual_machine" "XXXXXX": │ 239: project_reference { │ │ Blocks of type "project_reference" are not expected here. Did you mean to define argument "project_reference"? If so, use the equals sign to assign it │ a value.

Terraform Code:

resource "nutanix_virtual_machine" "XXXX" {
    for_each = local.vms
    name = "${each.value.name}"
    num_vcpus_per_socket = 1
    num_sockets          = 1
    memory_size_mib      = 2048
    cluster_uuid = local.cluster1
    nic_list {
        subnet_uuid = resource.nutanix_subnet.customer_subnets["subnet1"].id
    }
    disk_list {
        data_source_reference = {
            kind = "image"
            uuid = "XXXXXXX"
        }
        device_properties {
        disk_address = {
            device_index = 0
            adapter_type = "SCSI"
        }
        device_type = "DISK"
        }
    }
    categories { 
        name = "DR"
        value = "${each.value.dr}"
    }
    categories { 
        name = "Environment"
        value = "${each.value.environment}"
    }

    project_reference { 
        kind = "project"
        name = nutanix_project.testp1.name
        uuid = nutanix_project.testp1.uuid
    }

}

Nutanix Providers Tested: 1.8.0-beta.1 and 1.7.1 Terraform: v1.3.2

LloydVickeryASI avatar Nov 14 '22 03:11 LloydVickeryASI