Files
homelab-v/tofu/kubernetes/bootstrap/volumes/proxmox-volume/config.tf
T
Vegard Hagen 67f160fea1 fix(tofu): volume-provisioning
A Proxmox update probably broke/changed the way API requests are handled, giving errors on UPDATE calls with parameters that aren't used

Error: unexpected response code '400': {"data":null,"errors":{"format":"property is not defined in schema and the schema does not allow additional properties","vmid":"property is not defined in schema and the schema does not allow additional properties","size":"property is not defined in schema and the schema does not allow additional properties","filename":"property is not defined in schema and the schema does not allow additional properties"}}

Also update Mastercard/restapi provider
2025-04-17 18:24:03 +02:00

46 lines
1.0 KiB
Terraform

locals {
filename = "vm-${var.volume.vmid}-${var.volume.name}"
}
resource "restapi_object" "proxmox-volume" {
path = "/api2/json/nodes/${var.volume.node}/storage/${var.volume.storage}/content"
id_attribute = "data"
debug = true
data = jsonencode({
vmid = var.volume.vmid
filename = local.filename
size = var.volume.size
format = var.volume.format
})
// Proxmox returns a different object which we ignore.
// The size is also returned in bytes, not with prefix, e.g. 1G, 512Mi.
// Setting to false (default) triggers a change each run
ignore_all_server_changes = true
// Providing a supported parameter that doesn't do anything.
// Supplying either `null` or an empty object makes this fall back to the `data` object.
update_data = jsonencode({
node = var.volume.node
})
lifecycle {
prevent_destroy = false
}
}
output "node" {
value = var.volume.node
}
output "storage" {
value = var.volume.storage
}
output "filename" {
value = local.filename
}