Setup API key for Proxmox
warning
You should use a trusted certificate on your Proxmox node.
See this guide for reference:
https://3os.org/infrastructure/proxmox/lets-encrypt-cloudflare/#installation-and-configuration
Step 1: Create a user
- Log in to Proxmox.
- Go to Data center > Permissions > Users > Add.
- Enter:
- Username:
opentofu - Realm: Proxmox VE authentication.
- Username:
- Press Add.
Step 2: Create a role
- Go to Data center > Permissions > Roles.
- Press Create.
- Enter:
- Name:
opentofu-role - Privileges:
Datastore.AllocateSpaceDatastore.AuditVM.AllocateVM.AuditVM.CloneVM.Config.CDROMVM.Config.CPUVM.Config.CloudinitVM.Config.DiskVM.Config.HWTypeVM.Config.MemoryVM.Config.NetworkVM.Config.OptionsVM.MonitorVM.PowerMgmt
- Name:
Step 3: Create an API token
- Go to Data center > Permissions > API Tokens.
- Press Add.
- Select:
- User: the user you just created (
opentofu). - Token ID:
opentofu-token - Privilege Separation: unchecked.
- User: the user you just created (
- You now see a screen with the secrets.
Copy them now and store them.
Step 4: Prepare terraform.tfvars
Enter the token in the format:
Token ID + Secret
Example terraform.tfvars:
proxmox = {
name = "nuc"
cluster_name = "nuc"
endpoint = "https://nuc.pc-tips.se:8006"
insecure = false
username = "root"
api_token = "opentofu@pve!opentofu-token=313a1w3551awd5a1wd3a1wd5"
}