Open fmartingr opened 4 weeks ago
@fmartingr mountpoint is meant to have multiple blocks such that the terraform path is proxmox_lxc.container["key"].mountpoint["key"].storage
. The correct way to do this when done in a module is with dynamic.
dynamic "mountpoint" {
for_each = try(each.value.mountpoints, {})
content {
key = mountpoint.key
slot = tonumber(mountpoint.key)
storage = try(mountpoint.value.storage, "local-lvm")
volume = try(mountpoint.value.volume, null)
mp = try(mountpoint.value.mp, "/mnt/container/mp")
size = try(mountpoint.value.size, "8G")
acl = try(mountpoint.value.acl, false)
backup = try(mountpoint.value.backup, true)
replicate = try(mountpoint.value.replicate, false)
shared = try(mountpoint.value.shared, true)
}
}
In my case my input object looks like this for reference
containers = {
"mp-test" = {
description = "lxc test"
target = "pve1"
pool = "test"
template = "media:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst"
os_type = "debian"
unprivileged = true
onboot = false
hastate = "stopped"
hagroup = "ceph"
sshkeys = ""
rootfs_storage = "vmdisks"
tags = ["test"]
mountpoints = {
"0" = {
storage = "vmdisks"
mp = "/mnt/mp0"
}
"1" = {
storage = "vmdisks"
mp = "/mnt/mp1"
}
}
}
}
Hello,
I'm using this to handle my homelab and while refactoring it into modules I tried to use:
But apparently the
mountpoint
directive does not support for-each:And trying to run it complains about trying to use
each.value
: