Issue
Nutanix Cluster Information
Prism Central Version: pc.7.5.0.5
AOS Version: 7.5.0.5
Terraform Version
Terraform: v1.14.2
Provider: registry.terraform.io/nutanix/nutanix v2.4.0
Affected Resources
nutanix_virtual_machine_v2
Terraform Configuration Files
Create:
variable "cluster_ext_id" {
description = "ext id of the cluster"
type = string
}
data "template_file" "cloud_init" {
template = file("./files/cloud-init")
vars = {
vm_pw = "my_password"
}
}
resource "nutanix_images_v2" "image" {
name = "tf_my_complex_image_ubuntu"
description = "Description of a complex image."
type = "ISO_IMAGE"
source {
url_source {
url = "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
}
}
cluster_location_ext_ids = [var.cluster_ext_id]
}
resource "nutanix_virtual_machine_v2" "vm" {
name = "tf_my_custom_vm"
description = "simple vm desc"
num_cores_per_socket = 8
num_sockets = 1
memory_size_bytes = 4 * pow(1024, 3) # 4 GB
cluster {
ext_id = var.cluster_ext_id
}
guest_customization {
config {
cloud_init {
cloud_init_script {
user_data {
value = base64encode("${data.template_file.cloud_init.rendered}")
}
}
}
}
}
disks {
disk_address {
bus_type = "SCSI"
index = 0
}
backing_info {
vm_disk {
data_source {
reference {
image_reference {
image_ext_id = nutanix_images_v2.image.ext_id
}
}
}
disk_size_bytes = 20 * pow(1024, 3) # 20 GB
}
}
}
boot_config {
uefi_boot {
boot_order = ["NETWORK", "DISK", "CDROM"]
}
}
}
Update:
variable "vm_ext_id" {
description = "The ext id of a virtual machine"
type = string
}
data "template_file" "cloud_init" {
template = file("./files/updated-cloud-init")
vars = {
vm_pw = "my_password"
}
}
resource "nutanix_virtual_machine_v2" "vm" {
name = "tf_my_updated_vm"
description = "unknown"
num_cores_per_socket = 1
num_sockets = 1
cluster {
ext_id = "unknown"
}
guest_customization {
config {
cloud_init {
cloud_init_script {
user_data {
value = base64encode("${data.template_file.cloud_init.rendered}")
}
}
}
}
}
lifecycle {
ignore_changes = [description, num_cores_per_socket, num_sockets, cluster, cd_roms, disks]
}
}
import {
id = var.vm_ext_id
to = nutanix_virtual_machine_v2.vm
}
Debug Output
N/A
Panic Output
Expected Behaviour
When running an update for a cloud-init script, in this case change the contents of a file on the VM, it is expected that the contents of the file is changed.
Note: nutanix_virtual_machine destroys and recreates the VM in this scenario.
Actual Behaviour
Updating the cloud init does not seem to do anything. It does not give any errors or warnings, it says that the update was ok. But nothing actually happens on the VM.
CRUDI Operations
Create
✔️
Update
❌
Steps To Reproduce
- Create separate main.tf files with the tf configs above.
- Issue
terraform apply on the Create tf file
- Issue
terraform apply on the Update tf file
Important Factors
Original cloud-init script:
#cloud-config
users:
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
groups: [sudo]
lock_passwd: false
plain_text_passwd: ${vm_pw}
type: text
shell: /bin/bash
write_files:
- path: /home/ubuntu/test
content: test
Updated cloud-init script:
#cloud-config
users:
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
groups: [sudo]
lock_passwd: false
plain_text_passwd: ${vm_pw}
type: text
shell: /bin/bash
write_files:
- path: /home/ubuntu/test
content: updated
Issue
Nutanix Cluster Information
Prism Central Version: pc.7.5.0.5
AOS Version: 7.5.0.5
Terraform Version
Terraform: v1.14.2
Provider: registry.terraform.io/nutanix/nutanix v2.4.0
Affected Resources
nutanix_virtual_machine_v2
Terraform Configuration Files
Create:
Update:
Debug Output
N/A
Panic Output
Expected Behaviour
When running an update for a cloud-init script, in this case change the contents of a file on the VM, it is expected that the contents of the file is changed.
Note: nutanix_virtual_machine destroys and recreates the VM in this scenario.
Actual Behaviour
Updating the cloud init does not seem to do anything. It does not give any errors or warnings, it says that the update was ok. But nothing actually happens on the VM.
CRUDI Operations
Create
✔️
Update
❌
Steps To Reproduce
terraform applyon the Create tf fileterraform applyon the Update tf fileImportant Factors
Original cloud-init script:
Updated cloud-init script: