terraform { required_providers { proxmox = { source = "bpg/proxmox" version = "0.68.0" } } } provider "proxmox" { endpoint = "https://10.0.50.110:8006/" insecure = true api_token = trimspace(file("${path.module}/.secrets/api_token")) } variable "vm_gateway" { type = string description = "Default gateway for all virtual machines." default = "10.1.50.1" } variable "vm_addresses" { type = object({ alpha = string bravo = string charlie = string delta = string }) description = "CIDR formatted IPv4 addresses for each virtual machine (e.g. 10.1.50.130/24)." } resource "proxmox_virtual_environment_vm" "vm_alpha" { name = "terraform-multi-vm-alpha" node_name = "rbmk2" clone { vm_id = 169 full = true datastore_id = "local-lvm" } cpu { sockets = 1 cores = 2 } memory { dedicated = 4096 } network_device { model = "virtio" bridge = "vmbr0" } initialization { datastore_id = "local-lvm" user_account { username = "devops" keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFyVe1ZhUCVs9imt0UmcCIXRAHpoSKFQ7IH/ekEXohZG dzoni-wolkabout" ] } ip_config { ipv4 { address = var.vm_addresses.alpha gateway = var.vm_gateway } } } agent { enabled = true } } resource "proxmox_virtual_environment_vm" "vm_bravo" { name = "terraform-multi-vm-bravo" node_name = "rbmk2" clone { vm_id = 169 full = true datastore_id = "local-lvm" } cpu { sockets = 1 cores = 2 } memory { dedicated = 4096 } network_device { model = "virtio" bridge = "vmbr0" } initialization { datastore_id = "local-lvm" user_account { username = "devops" keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFyVe1ZhUCVs9imt0UmcCIXRAHpoSKFQ7IH/ekEXohZG dzoni-wolkabout" ] } ip_config { ipv4 { address = var.vm_addresses.bravo gateway = var.vm_gateway } } } agent { enabled = true } } resource "proxmox_virtual_environment_vm" "vm_charlie" { name = "terraform-multi-vm-charlie" node_name = "rbmk2" clone { vm_id = 169 full = true datastore_id = "local-lvm" } cpu { sockets = 1 cores = 2 } memory { dedicated = 4096 } network_device { model = "virtio" bridge = "vmbr0" } initialization { datastore_id = "local-lvm" user_account { username = "devops" keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFyVe1ZhUCVs9imt0UmcCIXRAHpoSKFQ7IH/ekEXohZG dzoni-wolkabout" ] } ip_config { ipv4 { address = var.vm_addresses.charlie gateway = var.vm_gateway } } } agent { enabled = true } } resource "proxmox_virtual_environment_vm" "vm_delta" { name = "terraform-multi-vm-delta" node_name = "rbmk2" clone { vm_id = 169 full = true datastore_id = "local-lvm" } cpu { sockets = 1 cores = 2 } memory { dedicated = 4096 } network_device { model = "virtio" bridge = "vmbr0" } initialization { datastore_id = "local-lvm" user_account { username = "devops" keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFyVe1ZhUCVs9imt0UmcCIXRAHpoSKFQ7IH/ekEXohZG dzoni-wolkabout" ] } ip_config { ipv4 { address = var.vm_addresses.delta gateway = var.vm_gateway } } } agent { enabled = true } }