Skip to content

Attaching volume group to VM invalidates state #1079

@jcantrell-ntnx

Description

@jcantrell-ntnx

Nutanix Cluster Information

PC/PE: 7.3

Terraform Version

1.12

Affected Resource(s)

  • nutanix_volume_group_vm_v2
  • nutanix_virtual_machine
  • nutanix_virtual_machine_v2

Terraform Configuration Files

resource "nutanix_volume_group_v2" "volume_group" {
  name                               = "vg-${random_pet.vg-name.id}"
  should_load_balance_vm_attachments = false
  sharing_status                     = "SHARED"

  cluster_reference = local.cluster_extId

  is_hidden = false

}

resource "nutanix_volume_group_disk_v2" "volume_group_disk" {
  volume_group_ext_id = nutanix_volume_group_v2.volume_group.ext_id
  index               = 1
  disk_size_bytes     = provider::units::from_gb(2)

  disk_data_source_reference {
    ext_id      = data.nutanix_storage_containers_v2.storage_container_ext_id.storage_containers[0].ext_id
    entity_type = "STORAGE_CONTAINER"
  }

  lifecycle {
    ignore_changes = [
      disk_data_source_reference
    ]
  }

}

resource nutanix_virtual_machine {
# Any VM configuration
}

resource "nutanix_volume_group_vm_v2" "vg_vm_attachment" {
  volume_group_ext_id = nutanix_volume_group_v2.volume_group.ext_id
  vm_ext_id           = module.vm.vm.id
}

Expected Behavior

A virtual machine and volume group are deployed and the volume group is attached to the virtual machine

Actual Behavior

A virtual machine and volume group are depoyed and attached, but on subsequent Terraform plan and apply actions, Terraform attempts to remove the volume group from the VM because the resulting disk was not part of the initial VM configuration.

Steps to Reproduce

  1. terraform apply

Important Factors

This can be worked around by specifying the volume group directly on a nutanix_virtual_machine_v2 and avoiding nutanix_volume_group_vm_v2, however there does not appear to be a workaround for nutanix_virtual_machine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions