Hello guys, this period I’m using terraform for creating virtual machines ( with disk_size_vm > disk_size_template) from a template (with 30 GiB of disk size in default ). When I launch the terraform destroy
or even terraform plan -destroy -out destroy_plan && terraform apply destroy_plan
, the vm cannot be deleted and the error is like this :
Error: disk.0: virtual disk “data”: virtual disks cannot be shrunk (old: 40 new: 30)
│
│ with vsphere_virtual_machine.vm,
│ on main.tf line 42, in resource “vsphere_virtual_machine” “vm”:
│ 42: resource “vsphere_virtual_machine” “vm” {
For instance, the server that I’m using has the version v1.13 of terraform, and when I tested my terraform project in another server with v0.14 it worked and the vm have been destroyed.
So, in this case we can say that the terraform version is the reason of the error, but I can’t have the right explanation behind this, because if terraform going to destroy a vm with a specific disk size, why is it required that the vm disk size needs to match the disk size of the template to do the destruction of the vm?
Does anyone know the explanation or the solution please!!