VSphere Provider, Instant Clones and managing post-clone state

Hello,

I’m currently adding functionality to support Instant Clones in the Terraform vSphere Provider and I’m looking for some advice on the best way to approach reconciling the cloned virtual machine with the desired Terraform State.

Specifically, once I’ve created the Instant Clone, its state is inherited from the VM from which it was cloned and any deviations from the Terraform plan would need to be corrected by invoking the reconfigure method.

This is a simple enough task but being an Instant Clone I only want to invoke a reconfiguration of the VM if one is actually required, as any reboot will eradicate any memory sharing benefits.

Looking at how a resourceVSphereVirtualMachineUpdate operation handles any deviation, it invokes the function expandVirtualMachineConfigSpec which compares the state with the diff. However, as this is a create operation, I have no existing state to work with and therefore get false positives with regard to whether changes have taken place and whether any reboots are required.

So my question is do I need to reproduce all the code in expandVirtualMachineConfigSpec and any functions it invokes in order to compare the state of the Instant Clone with the desired Terraform state, can I somehow force an update of the Diff prior to invoking expandVirtualMachineConfigSpec or is there any other means that currently evades me?