ProxMox and Terraform "VM '<id>' not found"

edymol

New Member
Nov 20, 2024
1
0
1
Hello.

I am new to ProxMox and perhaps this has been already asked, although I have not seen a similar question yet.

I am trying to use Terraform to provision my infrastructure in PoxMox but I keep on getting this error.
Code:
[CODE=bash][CODE]proxmox_vm_qemu.ubuntu_vm: Creating...
╷
│ Error: vm '8000' not found
│
│   with proxmox_vm_qemu.ubuntu_vm,
│   on main.tf line 16, in resource "proxmox_vm_qemu" "ubuntu_vm":
│   16: resource "proxmox_vm_qemu" "ubuntu_vm" {
[/CODE][/CODE]

I have created different users and roles to try to make it work but it has not worked
Screenshot 2024-11-20 at 11.41.55 AM.png

Here is the main.tf that I am using for this test

root@proxmox:~/devops/terraform# cat main.tf
terraform {
required_providers {
proxmox = {
source = "Telmate/proxmox"
version = ">= 2.9.11"
}
}
}

provider "proxmox" {
pm_api_url = var.pm_api_url
pm_user = var.pm_user
pm_password = var.pm_password
pm_debug = var.pm_debug

resource "proxmox_vm_qemu" "ubuntu_vm" {
name = "ubuntu_vm" # Name of the new VM
target_node = "proxmox" # Node where the VM will be created
clone = 8000 # Template ID for cloning the VM

# VM Resources
cpu = 2
memory = 2048
sockets = 1

# Disk Configuration
disk {
storage = "vm-pool" # Ensure this matches the storage pool for the template
size = "32G"
type = "scsi"
iothread = 1
}

# Network Configuration
network {
model = "virtio"
bridge = "vmbr0"
}

# Cloud-init Configuration
os_type = "cloud-init"
ssh_user = "devops-user"
sshkeys = file("~/.ssh/id_rsa.pub")
ipconfig0 = "ip=192.168.100.50/24,gw=192.168.100.1"
}

Here are the different templates I have created but all give back the same error.
Screenshot 2024-11-20 at 11.43.51 AM.png
I am using this versions

Bash:
root@proxmox:~/devops/terraform# pveversion
pve-manager/8.2.2/9355359cd7afbae4 (running kernel: 6.8.4-2-pve)


I also have used API token that works when used in CLI

Bash:
curl -k -X GET "https://192.168.100.27:8006/api2/json/version" -H "Authorization: PVEAPIToken=terraform@pve!terraform:285ecb71-6c"

Has anyone had the same issue recently and how was this solved?

Thank you for your help. Screenshot 2024-11-20 at 11.41.55 AM.pngScreenshot 2024-11-20 at 11.43.51 AM.png
 
Last edited:
Hi @edymol , welcome to the forum.

The terraform code is not maintained by PVE personnel, you would have to reach out to the creator of TF code for a definitive answer.
In the meantime, you can dig into the code yourself to see what API call is being generated, that may tell you what is wrong.
If there is a way to add some "print" statements, that could help as well.

Try to do the same thing via direct "curl", using your authentication token.

Good luck



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!