Skip to content

idempotence vm categories #1078

@aurelienlm

Description

@aurelienlm

Each time I run a tofu apply, a change is detected in the VM categories section

resource "nutanix_virtual_machine_v2" "toton_vpc_01-pri-ing01_az1" {
  provider                = nutanix.az1
  name                    = "toton_vpc_01-pri-ing01"
  num_cores_per_socket    = 1
  num_sockets             = 2
  memory_size_bytes       = 8 * pow(1024, 3) # 8 GB
  hardware_clock_timezone = "UTC" # always UTC for linux machine, modify only for windows machine
  power_state             = "ON"
  cluster {
    ext_id = data.nutanix_clusters_v2.shared_clu-corp-th3-npe012_az1.cluster_entities[0].ext_id
  }
  apc_config { 
    is_apc_enabled = true
  }
  cd_roms {
    disk_address {
      bus_type = "SATA"
      index    = 0
    }
  }
  disks {
    disk_address {
      bus_type = "SCSI"
      index    = 0
    }
    backing_info {
      vm_disk {
        data_source {
          reference {
            image_reference {
              image_ext_id = data.nutanix_images_v2.list-images-corp-uni-debian-13-az1.images[0].ext_id
            }
          }
        }
        disk_size_bytes = 50 * pow(1024, 3) # 50 GB
      }
    }
  }
  disks {
    disk_address {
      bus_type = "SCSI"
      index    = 1
    }
    backing_info {
      vm_disk {
        disk_size_bytes = 17 * pow(1024, 3) # 15 GB
        storage_container {
          ext_id = data.nutanix_storage_containers_v2.default_storage_containers_clu-corp-th3-npe012_az1.storage_containers[0].ext_id
        }
      }
    }
  }
  nics {
    network_info {
      nic_type = "NORMAL_NIC"
      subnet {
        ext_id = nutanix_subnet.toton_vpc_01_subnet_overlay_02_az1.id
      }
      vlan_mode = "ACCESS"
      ipv4_config {
        should_assign_ip = true
        ip_address {
          value = "192.168.100.113"
        }
      }
    }
  }
  boot_config {
    legacy_boot {
      boot_order = ["CDROM", "DISK", "NETWORK"]
    }
  }
  categories{
    ext_id = nutanix_category_v2.toton_vpc_01_category_ing_server_value_az1.id
  }
  categories{
    ext_id = nutanix_category_v2.toton_vpc_01_category_disaster_recovery_crash_consistent_value_az1.id
  }
  guest_customization {
      config {
        cloud_init {
          cloud_init_script {
            user_data {
              value = base64encode(file("cloud_config.yml"))
            }
          }
        }
      }
    }

  lifecycle {
    ignore_changes = [
      guest_customization, cd_roms, disks.0.backing_info.0.vm_disk.0.data_source, nics[0].network_info[0].ipv4_config[0].should_assign_ip
    ]
  }
}

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