I’m trying to clone a Windows Server 2019 VM using Terraform with the vSphere provider. The clone process starts and the VM is created, but it gets deleted shortly after because the customization does not complete successfully. I receive the following error during the customization phase:
The number of network adapter settings in the customization specification: 0 does not match the number of network adapters present in the virtual machine: 1.
Here’s the relevant part of my Terraform code:
network_interface {
network_id = data.vsphere_network.network.id
adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]
}
I am not setting any static IPs, and I expect the network adapter to be configured dynamically (via DHCP). Has anyone encountered this issue before? How can I resolve this and ensure that Terraform correctly handles the network adapter settings during customization so the VM doesn’t get deleted?
The network adapter of the Windows Server 2019 VM i want to clone
I tried matching the network adapter configuration with the template settings, using DHCP for dynamic IP assignment, and ensuring the adapter types were correct. I expected the clone to complete successfully with the network adapter properly configured, but the VM still gets deleted after the clone due to the customization error.