Keep_on_remove=true unable to be set but the implied value is false?

I’m creating a couple of disks via vsphere_virutal_disk resource. I am then attaching them to a vsphere_virtual_machine resource in the disk block.

When destroying the VM, the attached disks also get destroyed. I tried to add keep_on_remove to each disk but I would get an error on apply that the value was implicit when attach was set.

When looking back at the destroy output I see:

...
- keep_on_remove   = false -> null
...

Am I misunderstanding the use and purpose of this attribute? Is this expected behavior? If so, then how would you keep the created disks when destroying the VM?

Thanks

I would guess that what the documentation is trying to suggest, is that an attached disk isn’t considered part of the VM anyway, so it wouldn’t be removed on VM removal anyway.

But I’ve never actually used vSphere so I don’t know if that’s actually how it works.

Just to confirm, you’re not also destroying your vsphere_virtual_disk resources, are you? Maybe post the entire terraform plan output?

How would you not destroy the disks if the resources are defined in the same root module as the VM?

Is the point to create the disks in one module and then have a separate module just for the VM that uses the attached disks?

Maybe that is where the disconnect is? The documentation doesn’t provide a good example on how this is resource is used.

Delete the VM’s resource block - do not delete the disks’ resource blocks.