diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index 2955a0ea3a5f..ebbb300ffab3 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -218,6 +218,11 @@ func resourceVSphereVirtualMachine() *schema.Resource { Default: false, }, + "uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "custom_configuration_parameters": &schema.Schema{ Type: schema.TypeMap, Optional: true, @@ -1071,6 +1076,7 @@ func resourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{}) d.Set("memory_reservation", mvm.Summary.Config.MemoryReservation) d.Set("cpu", mvm.Summary.Config.NumCpu) d.Set("datastore", rootDatastore) + d.Set("uuid", mvm.Summary.Config.Uuid) return nil } diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine_test.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine_test.go index 663f5c6c0fad..a9cb82bce414 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine_test.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine_test.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "os" + "regexp" "testing" "path/filepath" @@ -237,6 +238,7 @@ func (test TestFuncData) testCheckFuncBasic() ( return testAccCheckVSphereVirtualMachineExists(vmName, &test.vm), resource.TestCheckResourceAttr(vmName, "name", res), resource.TestCheckResourceAttr(vmName, "vcpu", cpu), + resource.TestMatchResourceAttr(vmName, "uuid", regexp.MustCompile("[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}")), resource.TestCheckResourceAttr(vmName, "memory", mem), resource.TestCheckResourceAttr(vmName, "disk.#", disks), resource.TestCheckResourceAttr(vmName, "network_interface.#", "1"), diff --git a/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown b/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown index 677821c9b760..5015ac6c42d2 100644 --- a/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown +++ b/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown @@ -135,6 +135,7 @@ The `cdrom` block supports: The following attributes are exported: * `id` - The instance ID. +* `uuid` - The instance UUID. * `name` - See Argument Reference above. * `vcpu` - See Argument Reference above. * `memory` - See Argument Reference above.