nutanix / terraform-provider-nutanix

Terraform Nutanix Provider
https://www.terraform.io/docs/providers/nutanix/
Mozilla Public License 2.0
100 stars 112 forks source link

nutanix_virtual_machine ignores storage container definition, when used together with image data_source_reference #686

Open Philbow opened 1 month ago

Philbow commented 1 month ago

Nutanix Cluster Information

Terraform Version

Affected Resource(s)

Terraform Configuration Files

resource "nutanix_virtual_machine" "vm" {
  name         = "nutanix_reproducable"
  cluster_uuid = "###ADD_YOUR_VALUE###"

  num_vcpus_per_socket = 2
  num_sockets          = 1
  memory_size_mib      = 2048

  disk_list {
    data_source_reference = {
      kind = "image"
      uuid = "<desired_image_uuid>"
    }

    storage_config {
      storage_container_reference {
        kind = "storage_container"
        uuid = "###ADD_YOUR_VALUE###"
      }
    }

    device_properties {
      device_type = "DISK"
      disk_address = {
        device_index = 0
        adapter_type = "SCSI"
      }
    }
    disk_size_mib = 20480
  }

  nic_list {
    subnet_uuid = "###ADD_YOUR_VALUE###"
  }
}

Debug Output

Expected Behavior

When using a data_source_reference with image, Terraform should use the correctly specified storage container in the first run, to omit unsupported changes in the second run.

Actual Behavior

When using a data_source_reference with image, Terraform uses a wrong storage container (SelfServiceContainer) in the first run.

Steps to Reproduce

  1. terraform apply -auto-approve
  2. terraform apply to see unplanned changes or check the storage container in the UI from the first run

Important Factors

pipoe2h commented 1 month ago

@Philbow, by design, you cannot choose a different storage container when creating a VM from an existing image. You can check this by following the steps through the Prism Central interface.

To understand this better, is your intention to add an additional disk to the virtual machine, or to specify where to store the cloned image disk for that VM?

Philbow commented 1 month ago

Sure I forgot that the image is only referenced in the VM to reduce storage usage - this makes sense.

A second disk without image reference would use the defined storage container.

An error for mutual exclusivness would be helpful. Please decide if this makes sense or not (and close the ticket if you wish so).

Thanks for the quick response.