Make VMs dynamic with for_each map — spin up/down any number by name

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ludwig Mey
2026-09-28 20:04:45 +13:00
co-authored by Claude Sonnet 4.6
parent b8ce272610
commit dad5376064
3 changed files with 31 additions and 43 deletions
+10 -29
View File
@@ -1,5 +1,5 @@
variable "proxmox_api_token" {
description = "Proxmox API token in the format user@realm!token_name=secret"
description = "Proxmox API token — format: user@realm!token_name=secret"
type = string
sensitive = true
}
@@ -11,35 +11,16 @@ variable "ssh_private_key_path" {
}
variable "ssh_public_key" {
description = "SSH public key to inject into created VMs"
description = "SSH public key injected into created VMs"
type = string
}
variable "vm_name" {
description = "Name of the VM to create"
type = string
default = "debian-vm"
}
variable "vm_id" {
description = "Proxmox VM ID (100-999 for regular VMs)"
type = number
default = 100
}
variable "vm_cores" {
type = number
default = 2
}
variable "vm_memory" {
description = "Memory in MiB"
type = number
default = 2048
}
variable "vm_disk_size" {
description = "Disk size in GiB"
type = number
default = 20
variable "vms" {
description = "Map of VMs to create. Key becomes the VM hostname."
type = map(object({
cores = optional(number, 2)
memory = optional(number, 2048)
disk_size = optional(number, 20)
}))
default = {}
}