Skip to content

Basic

For-loop

variable "machines" {
description = "Cluster machines"
type = map(object({
node_type = string
ip = string
netmask = string
}))
default = {
vm1 = {
node_type = "worker"
ip = "192.168.1.5"
netmask = "255.255.255.0"
}
}
}
//...
resource "vsphere_virtual_machine" "worker" {
for_each = {
for name, machine in var.machines :
name => machine
if machine.node_type == "worker"
}
}