Terraform with Proxmox – My Experience

When I first started using Terraform to manage Proxmox, I had to go through a few setup steps to get everything running smoothly. Here’s my walkthrough that helped simplify automation and provisioning.

Step 1: Create an API Token in Proxmox

  1. Go to Datacenter β†’ Permissions β†’ API Tokens in the Proxmox web UI.
  2. Create a new API token for your user.
  3. Assign permissions (e.g. PVEAdmin or PVESysAdmin).
  4. Store your token securely.
Create API token step 1 API token creation screen

Step 2: Save Your API Token in Terraform

I configured my Terraform provider using the credentials.auto.tfvars file:

Terraform credentials file example Terraform file showing API token values

Never expose your API token publicly. Keys shown here have been rotated and are from my home lab.

Step 3: Use My Template Repo

I used my GitHub repo to simplify the VM cloning setup:

github.com/malcolmso/Proxmox-Terraform

  1. Clone the repo: git clone https://github.com/malcolmso/Proxmox-Terraform.git
  2. Update credentials.auto.tfvars with your Proxmox settings
  3. Run terraform init
  4. Run terraform plan -var-file="credentials.auto.tfvars"
  5. Run terraform apply -var-file="credentials.auto.tfvars" -auto-approve

Final Thoughts

This setup helped me automate VM provisioning in Proxmox using Terraform. By leveraging API keys and a structured Terraform config, I was able to streamline workflows and eliminate manual steps. I highly recommend starting with the GitHub template and customizing it to your needs.