VM Not found when cloning with Terraform

sugarat

New Member
Dec 10, 2024
3
0
1
Hi there. I have installed Proxmox VE as I would like to be able to spin up VM's using Terraform. I am using the Proxmox provider with Terraform, but when attempting to provision, I see the following error:

Code:
proxmox_vm_qemu.testNode[0]: Creating...
╷
│ Error: vm 'VM 500' not found
│
│   with proxmox_vm_qemu.testNode[0],
│   on main.tf line 1, in resource "proxmox_vm_qemu" "testNode":
│    1: resource "proxmox_vm_qemu" "testNode" {
│

Now I realise that this is not a support forum for Terraform, but the strange thing is that this VM does exist on my Proxmox server, so I'm not sure why this error is happening.

Code:
root@solomon:~# qm list
      VMID NAME                 STATUS     MEM(MB)    BOOTDISK(GB) PID       
       101 cloudtest            stopped    2048              32.00 0         
       500 VM 500               stopped    256               10.00 0

So the VM is there... I don't understand why I am being told it does not exist. Does anyone else use Terraform Proxmox provider to provision VM's who knows what could be wrong here. Thanks very much.
 
Hi,

the actual TF code you used would definitely help here. But assuming from the error message, you might just have set the VMID argument (or whatever that is called with your provider) to VM 500 - but you need to use just 500 in that case, if it works as it sounds like.

VMs are always addressed by their unique, numeric VM ID in Proxmox VE, not their (human-readable) name.
 
Hi, thanks for the response. I thought this may be the case also. However, when I use the VMID it says the same thing.

Here's the terraform:

Code:
resource "proxmox_vm_qemu" "testNode" {
        count = 1
        name = "node0${count.index + 1}.mydomain.intra"
        target_node = "gabriel"
        vmid = "101${count.index + 1}"
        clone = "500"
        os_type = "cloud-init"
        cpu = "kvm64"
        cores = 2
        sockets = 1
        memory = 6144
        scsihw = "virtio-scsi-pci"
        bootdisk = "scsi0"

        disk {
                slot = 0
                size = "50G"
                type = "scsi"
                storage = "disk0"
                iothread = 1
        }   

        network {
                model = "virtio"
                bridge = "vmbr0"
                tag = 101
                firewall = false
                link_down = false
        }   

        ipconfig0 = "ip=192.168.1.20/24,gw=192.168.1.1"
        ciuser = "terraform"
}

I am now using Clone = "500" ie: the VMID. I know this is the VMID as I can see it:

Code:
      VMID NAME                 STATUS     MEM(MB)    BOOTDISK(GB) PID       
       101 cloudtest            stopped    2048              32.00 0         
       500 VM 500               stopped    256               10.00 0

The result is still the same:

Code:
│ Error: vm '500' not found
│
│   with proxmox_vm_qemu.testNode[0],
│   on main.tf line 1, in resource "proxmox_vm_qemu" "testNode":
│    1: resource "proxmox_vm_qemu" "testNode" {
│
╵

I suspect something related to permissions could be the problem. However, I've given the API user 'Administrator' permissions and told it to propagate down from / so that should be okay..? Hmmm
 
Error: vm 'VM 500' not found
500 VM 500
The actual VMID number (500) looks good.
The VM name "VM 500" is NOT.
As far as I can tell spaces are not allowed in the VM name. I tried this right now in the Proxmox GUI VM creation wizard & it refuses to proceed with a space in the name. Although it is interesting that in CLI/programming you actually managed to register that name of "VM 500", I still imagine this to be a source of error.
 
Good spot, although this doesn't seem to resolve the issue unfortunately :-(

Code:
root@solomon:~# qm list
      VMID NAME                 STATUS     MEM(MB)    BOOTDISK(GB) PID       
       101 cloudtest            stopped    2048              32.00 0         
       500 VM500                stopped    256               10.00 0


Terraform output:

Code:
│ Error: vm 'VM500' not found
│
│   with proxmox_vm_qemu.testNode[0],
│   on main.tf line 1, in resource "proxmox_vm_qemu" "testNode":
│    1: resource "proxmox_vm_qemu" "testNode" {
│

I think I'm going to nuke the thing from orbit and start again. I've obviously done something squiffy somewhere along the line. Thanks anyhow!
 

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!