Open louhisuo opened 1 year ago
Hello @kullervo610
As discussed in issue #205 there are no ways (for now) to somehow parse the ID returned form API. Maybe someone will find a workaround for this or it will be fixed on the provider's side
Apologies for the slow reply. I haven't attempted this in a while, but I think you could use native variable interpolation in Terraform for this rather than the provider's interpolation. Something like this?
resource "restapi_object" "zvol" {
provider = restapi.truenas
path = "/pool/dataset"
data = jsonencode({
name = var.vm_instance.zvol.name
type = "VOLUME"
volsize = 1073741824 # 1GiB
volblocksize = "8K"
})
create_path = "/pool/dataset"
destroy_path = "/pool/dataset/id/${var.vm_instance.zvol.name}"
read_path = "/pool/dataset/id/${var.vm_instance.zvol.name}"
update_path = "/pool/dataset/id/${var.vm_instance.zvol.name}"
}
This may just work because you can predict the path based on an input
I am working with below resource which gets created without any issues but never gets destroyed. Resource object has custom
destroy_path
which differs fromcreate_path
and non typicalìd
(in this example casenpool/vms/test-vm-bootvolume
) which constructed of ZFS dataset path (npool/vms
) and zvol name (test-vm-bootvolume
).{id} required to destroy resource is same same as 'name' submitted during create and with
terraform show
as seen from sniplet below I can confirm thatname
andid
matches after resource is created. I have some doubts if I should useid_attribute
and did some experiments with that as well without success.Any advice how to get destroy resource working?