The whole thing is provisioned with Tofu; and one of my favorite things to do is to verify that the end-to-end provisioning works fine.
So that means a lot of "tofu destroy" + "tofu apply".
However, the TF configuration includes the Talos disk images used by the cluster, and I didn't want to re-download them every single time.
My first intention was to use "tofu taint" on the virtual machines. But they are declared in a for_each block; and you can't use "tofu taint" or "tofu plan -replace" on a for_each resource (unless you enumerate each resource individually).
However, you can do a targeted destroy:
tofu plan -destroy -target proxmox_virtual_environment_vm.k8s_nodes
And destroy will follow dependencies (if you destroy a resource, the resources that depend on it will automatically be destroyed), so in my case I could also do e.g.:
tofu plan -destroy -target talos_machine_secrets.this
(Because pretty much every Talos-related resource depends on this directly or indirectly).
#terraform #opentofu #talos #kubernetes #homelab #selfhosted