terraform { required_providers { proxmox = { source = "bpg/proxmox" version = "0.111.1" } } } # --------------------------------------------------------------- # Cloud‑Init snippet – must live in the same module as the VM # --------------------------------------------------------------- resource "proxmox_virtual_environment_file" "cloud_config" { content_type = "snippets" datastore_id = "local" node_name = "watari" source_raw { data = file("${path.module}/user-data.yaml") file_name = "debian-cloud-config.yaml" } } resource "proxmox_virtual_environment_download_file" "debian_cloud_image" { content_type = "import" datastore_id = "local" node_name = "watari" url = "https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.qcow2" } resource "proxmox_virtual_environment_vm" "debian_vm" { name = "grailvm" node_name = var.node_name initialization { user_data_file_id = proxmox_virtual_environment_file.cloud_config.id ip_config { ipv4 { address = var.ip_address gateway = var.gateway } } dns { servers = ["1.1.1.1", "8.8.8.8"] } user_account { username = "root" password = var.password # keys = [trimspace(tls_private_key.example.public_key_openssh)] } } network_device { bridge = "vmbr0" } disk { datastore_id = var.datastore_id import_from = proxmox_virtual_environment_download_file.debian_cloud_image.id interface = "virtio0" iothread = true discard = "on" size = var.disk_size_gb } tags = ["deb13", "terraform"] cpu { cores = var.cores } memory { dedicated = var.memory ## invalid for vms swap = var.swap } agent { enabled = true } startup { order = "3" up_delay = "60" down_delay = "60" } }