Instead of doing a "virsh undefine " on the host to power-off a VM, is there a way I can do it using terraform?
I tried editing the terraform.tfstate file and trying to do a "terraform plan/apply -replace", but I am hitting some issues, realized that editing tfstate files will not work (and it's not advised to manually edit them)
And trying to modify the workspace tfvars variable and running apply doesn't "overwrite" it, it throws an error saying domain already exists.
Any suggestions would be appreciated, thanks in advance.
I use terraform-libvirt for my homelab so i searched same answer. My solution:
first of all i decided to add "running" variable and change in to true o false as i need, but it didn't work. Then i added null-resource with if-else condition and it worked:
resource "libvirt_domain" "domain-name"block:do nothing