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

Modifying VM image uuid (data_source_reference in disk_list) does not replace Disk

Open yannickstruyf3 opened this issue 4 years ago • 2 comments

Nutanix Cluster Information

  • Nutanix Cluster: 5.17.x
  • Nutanix Prism Central: 2020.7

Terraform Version

Terraform v0.12.24

Affected Resource(s)

  • nutanix_virtual_machine

Terraform Configuration Files

Create VM with a disk that references an image:

  disk_list {
    data_source_reference = {
      kind = "image"
      uuid = <image_id_1>
    }
    # disk_size_bytes = 90 * 1024 * 1024 * 1024
  }

Change the image id and apply:

  disk_list {
    data_source_reference = {
      kind = "image"
      uuid = <image_id_1>
    }
    # disk_size_bytes = 90 * 1024 * 1024 * 1024
  }

Debug Output

None

Panic Output

None

Expected Behavior

Change is visible in terraform plan and the disk image is swapped after terraform apply

Actual Behavior

Change is visible in terraform plan and but the disk image on the VM stays identical to the initial configuration. This also results in the fact that re-running terraform apply will keep on indicating that there is a new change.

Steps to Reproduce

  1. Create a VM with an image
  2. Update the image UUID
  3. Apply the modified config

Important Factors

Using Prism Central ​

References

--->

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

yannickstruyf3 avatar Aug 05 '20 07:08 yannickstruyf3

Alternative approach would be to set ForceNew on the image disk.

yannickstruyf3 avatar Sep 17 '20 11:09 yannickstruyf3

Copying from slack's conversation:

I think customize diff (#173) could not work for us: I tested it by changing without any luck:

  • data_source_reference to typelist.
  • change disk_list to typeSet
  • removing computed values from disk_list and test.

We can get the change only by adding or removing elements as your current implementation (#157), also I upgraded the provider to the new terraform SDK v1 to see if the behavior is different.

Also, I got from Hashicorp: customizediff is sort of actively discouraged, despite not having a replacement

  • We have two option around this issue:
  • Use the first workaround you proposed (#161).
  • Let the user know about updating the data_source reference is not possible by Terraform and should use terraform taint to force the VM recreation. https://www.terraform.io/docs/commands/taint.html

cc @yannickstruyf3

marinsalinas avatar Oct 27 '20 21:10 marinsalinas