hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
612 stars 449 forks source link

VM is recreated after changing non-destructive resources #2267

Open svg-mn opened 4 hours ago

svg-mn commented 4 hours ago

Community Guidelines

Terraform

1.9.6

Terraform Provider

2.9.2

VMware vSphere

8.0.2

Description

When using the vSphere Terraform provider, certain resource changes that should not require the destruction and recreation of the virtual machine (such as changing the VM name or adjusting CPU count) are causing the provider to unnecessarily destroy and recreate the VM. This behavior leads to service disruption and increased downtime, which is not expected for these types of changes.

Affected Resources or Data Sources

resource/vm

Terraform Configuration

resource "vsphere_virtual_machine" "example" { name = "example-vm" num_cpus = 2 memory = 4096 resource_pool_id = "resgroup-123" datastore_id = "datastore-123"

network_interface { network_id = "network-123" adapter_type = "vmxnet3" }

disk { label = "disk0" size = 50 } }

Debug Output

I can't link the debug GitHub log since it's not connected to the internet

Panic Output

No response

Expected Behavior

Changes to non-destructive fields (like the VM name, CPU count) should be applied in place without triggering a VM destruction and recreation.

Actual Behavior

When modifying resources like the VM name or CPU count Terraform plans to destroy the existing VM and recreate a new one. These changes should instead be updated without needing to delete and recreate the virtual machine.

Steps to Reproduce

  1. Deploy a VM using the vsphere_virtual_machine resource.

  2. Change the name, CPU, or memory allocation in the Terraform configuration.

  3. Run terraform plan and observe that it plans to destroy and recreate the VM instead of updating the resources in place.

Environment Details

No response

Screenshots

No response

References

No response

github-actions[bot] commented 4 hours ago

Hello, svg-mn! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.