I’m trying to deploy 3 vm’s in proxmox with terraform but I have errors and I don’t know why.
│ Error: Incorrect attribute value type
│
│ on ../resources/proxmox/main.tf line 2, in resource “proxmox_vm_qemu” “vm”:
│ 2: name = var.vm_name
│ ├────────────────
│ │ var.vm_name is a list of string
│
│ Inappropriate value for attribute “name”: string required.
╵
│ Error: Incorrect attribute value type
│
│ on ../resources/proxmox/main.tf line 4, in resource “proxmox_vm_qemu” “vm”:
│ 4: vmid = var.vmid
│ ├────────────────
│ │ var.vmid is a list of number
│
│ Inappropriate value for attribute “vmid”: number required.
main.tf
module "vm" {
source = "../resources/proxmox"
vm_name = var.vm_name
vmid = var.vmid
agent = 1
vm_count = var.vm_count
pve_node = "pve"
template_name = var.template_name
full_clone = true
proxmox_api_url = var.proxmox_api_url
proxmox_api_user = var.proxmox_api_user
proxmox_api_password = var.proxmox_api_password
}
variable.tf
variable "proxmox_api_url" {
type = string
}
variable "proxmox_api_user" {
type = string
sensitive = true
}
variable "proxmox_api_password" {
type = string
sensitive = true
}
variable "vm_name" {
type = list(string)
}
variable "vmid" {
type = list(number)
}
variable "template_name" {
type = string
}
variable "vm_count" {
type = number
}
env.tfvars
proxmox_api_url = "https://10.0.0.1:8006/api2/json"
proxmox_api_user = "user@pve"
proxmox_api_password = "hiddenpass"
vm_name = ["host0", "host1", "host2"]
vmid = [240, 241, 242]
template_name = "ubuntu-24"
vm_count = 3
Trying to deploy 3 ubuntu machines in Proxmox
Tomer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.