Include externally added disks into terraform

Hello All,

I have created a VM in vSphere thru terraform code and all looks good. I am testing a scenario of adding a disk outside of terraform (added a disk to VM from vSphere console)

When I run a plan, its detecting adrift and suggesting a deletion of disk saying “orphaned_disk_0” . I have expected this.

Now I have update my respective terraform VM code block and included it with respective attributes as below

“disk3” = {
size_gb = 50,
unit_number = 3
}

Running the plan is still suggesting to delete the 3rd disk added in vSphere and create this as new disk.

As per the terraform documentation, orphaned_disk_ prefix is used to label the disks not managed by terraform.

So if this situation happen, what would be the ideal way to include this into my terraform code (and into state) so that I will not face this issue.

thank you in advance

Regards,
PD

I am not familiar with vSphere, or terraform-provider-vsphere … but just thinking about Terraform core concepts, unless the provider incorporated some special attributes to cope with this - which it doesn’t seem to, based on its documentation - then the only thing you could possibly do would be to remove the entire VM from the Terraform state and re-import it… which feels clumsy and error prone.

I would guess that the provider does not offer a good way of doing this. It is sadly not unusual for things to get very messy when the same objects are being partly managed via Terraform, and partly not.

It might be worth opening an issue in the provider’s issue tracker and seeing if you get any reactions there.