Closed ericb-summit closed 3 years ago
Your the first that asked for this feature, so I don't believe there's a big demand for it...
In terms of terraform, when you want to keep a resource, but delete it from terraform, you simply remove the reference to that resource and do nothing to the actual resource. (This is all done in code of course). So technically, it can be done for anything regardless if there's a way to do it in api/commands.
Of course this whole request goes against terraform philosophy....
A simple solution is to just create a terraform code for your disks. Then use the output of it as an input to your vms using data sources.
https://www.terraform.io/docs/language/data-sources/index.html
I suspect that Powershell api is for center only.
The "keep_on_delete" is a vsphere artifact. Basically, it lets me separate my process in two separate terraform components. One is for persistent storage. The other is for the VMs running the apps, which reference the persistent storage. These are separate scripts, intentionally, because I want to handle persistency separately.
If I delete the VM in ESXI/vCenter, ESXI knows which VMDK to delete with the VM and which not to delete. This is super useful. I suspect most people looking for this level of complexity end up deploying things in k8s or openstack, etc..
Thanks for the feedback, I'll close this at this time.
So part of what I do in vsphere deployments is provision non ephemeral storage using
prevent_destroy
(to make it really non ephemeral), and then I create ephemeral VMs and attach the disk usingkeep_on_remove
flag.Eventually I tracked this flag down to the
keepAfterDeleteVm
flag found here https://vdc-download.vmware.com/vmwb-repository/dcr-public/da47f910-60ac-438b-8b9b-6122f4d14524/16b7274a-bf8b-4b4c-a05e-746f2aa93c8c/doc/vim.vslm.VStorageObjectControlFlag.htmlI found a way to use
vim-cmd
to dump that flag. But I couldn't find a way to set it usingvim-cmd
.Using the PowerShell API I see it's possible to set that flag, but that may be a vCenter API.
Anyways, what's your take on this?