I am provisioning multiple vm's using below templates:
resource "vsphere_virtual_machine" "vm" {
for_each = var.vms
name = each.value.name
folder = var.vsphere_folder
num_cpus = var.vm_cpus
memory = var.vm_memory
firmware = data.vsphere_virtual_machine.template.firmware
efi_secure_boot_enabled = data.vsphere_virtual_machine.template.efi_secure_boot_enabled
guest_id = data.vsphere_virtual_machine.template.guest_id
scsi_type = data.vsphere_virtual_machine.template.scsi_type
datastore_id = data.vsphere_datastore.datastore.id
resource_pool_id = data.vsphere_resource_pool.pool.id
}
I am looking to retrieve the uuid of these 6 instances as below and it does not work:
vsphere_virtual_machine.vm.*.uuid
How can I get the UUID's?
Code where I am using it:
module abc {
source = "../../abc"
for_each = var.vms
re = vsphere_virtual_machine.vm.*.uuid
}
I see where your confusion is and I think is best clarified with an example:
in this example the
local.vmis the equivalent to yourvsphere_virtual_machine.vmif we just need the list we can do with the value function as suggested by Marko but if we need to pass information to another resource or a module we can loop with the
for_eachlike you did initially in your vmYour module will look something like