hi everyone and thanks for your great tools !
i have the following as input variable (through command line) :
variable "virtual_machines" {
type = map(object({
Gateway = optional(string,"172.21.10.1")
VersionWindows = optional(string,"19")
OSType = optional(string,"CORE")
ServerType = optional(string,"GENERIC")
IP= optional(string,"192.168.9.10")
CPU=optional(number,2)
Memory=optional(number,4096)
WindowsKey=optional(string,"Nokey")
Network=optional(string,"vxw-dvs-38-virtualwire-6-sid-5005-VXLAN_FRONTEND")
}
)
)
}
The key here is the ostype/VersionWindows : i need to iterate that class with for_each, and i need to use a different template for each of my vm : “WindowsServerCore22”, “WindowsServerGUI19” for instance
before implementing the for_each, i used the following code :
data "vsphere_virtual_machine" "template" {
name = "${local.vsphere_virtual_machine_template}"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
locals {
vsphere_virtual_machine_template="Template-${var.OSType}${var.VersionWindows}"
}
So here, the challenge for me would be to dynamically change the : name = “${local.vsphere_virtual_machine_template}” instruction according to the variables in the foreach…
Do someone have an idea ?
Thanks in advance for your help !
Olivier