Codifying the Proxmox Cluster with Least-Privilege Terraform
Moving cluster provisioning to Terraform with a dedicated API role that can build and snapshot guests but cannot touch users, realms or host configuration.

Key Architectural Takeaways
- Provisioning authenticates with a dedicated scoped role, not root.
- The role deliberately omits user, realm, group and host-modification privileges.
- Terraform state is treated as a secret and never committed.
Why Terraform, and why carefully
The cluster had been built by hand. Before adding more guests we wanted every VM and container defined in code, which means giving automation real power over the hypervisor. The question was how little power it needs.
A role that can build, but not govern
We created a dedicated role and API token for provisioning. It can allocate, configure, clone, snapshot and power-manage guests and allocate datastore space for them. It deliberately cannot modify users, permissions, realms, storage definitions or node configuration. If the token leaked, an attacker could not use it to take over the cluster's identity or host layer.
Habits we kept
- Review the permission list before running anything.
- Scaffold first, then import and reconcile real state instead of recreating it.
- Keep state files out of the repository entirely.
Result
The cluster's guests are now declared in version control, and later automation, including Ansible baselines and the delivery pipeline, builds on this foundation.