Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion internal/services/compute/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ func virtualMachineOSDiskSchema() *pluginsdk.Schema {
Optional: true,
Default: false,
},

"id": {
Type: pluginsdk.TypeString,
Computed: true,
},
},
},
}
Expand Down Expand Up @@ -327,6 +332,7 @@ func flattenVirtualMachineOSDisk(ctx context.Context, disksClient *disks.DisksCl
storageAccountType := ""
secureVMDiskEncryptionSetId := ""
securityEncryptionType := ""
osDiskId := ""

if input.ManagedDisk != nil {
storageAccountType = string(pointer.From(input.ManagedDisk.StorageAccountType))
Expand Down Expand Up @@ -365,6 +371,8 @@ func flattenVirtualMachineOSDisk(ctx context.Context, disksClient *disks.DisksCl
diskEncryptionSetId = *disk.Model.Properties.Encryption.DiskEncryptionSetId
}
}

osDiskId = id.ID()
}

if securityProfile := input.ManagedDisk.SecurityProfile; securityProfile != nil {
Expand All @@ -382,9 +390,10 @@ func flattenVirtualMachineOSDisk(ctx context.Context, disksClient *disks.DisksCl
return []interface{}{
map[string]interface{}{
"caching": string(pointer.From(input.Caching)),
"disk_size_gb": diskSizeGb,
"diff_disk_settings": diffDiskSettings,
"disk_encryption_set_id": diskEncryptionSetId,
"disk_size_gb": diskSizeGb,
"id": osDiskId,
"name": name,
"storage_account_type": storageAccountType,
"secure_vm_disk_encryption_set_id": secureVMDiskEncryptionSetId,
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/linux_virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `identity` - An `identity` block as documented below.

* `os_disk` - An `os_disk` block as documented below.

* `private_ip_address` - The Primary Private IP Address assigned to this Virtual Machine.

* `private_ip_addresses` - A list of Private IP Addresses assigned to this Virtual Machine.
Expand All @@ -404,6 +406,12 @@ An `identity` block exports the following:

* `tenant_id` - The Tenant ID associated with this Managed Service Identity.

---

An `os_disk` block exports the following:

* `id` - The ID of the OS disk.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions:
Expand Down
10 changes: 9 additions & 1 deletion website/docs/r/windows_virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The following arguments are supported:

* `network_interface_ids` - (Required). A list of Network Interface IDs which should be attached to this Virtual Machine. The first Network Interface ID in this list will be the Primary Network Interface on the Virtual Machine.

* `os_disk` - (Required) A `os_disk` block as defined below.
* `os_disk` - (Required) An `os_disk` block as defined below.

* `resource_group_name` - (Required) The name of the Resource Group in which the Windows Virtual Machine should be exist. Changing this forces a new resource to be created.

Expand Down Expand Up @@ -395,6 +395,8 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `identity` - An `identity` block as documented below.

* `os_disk` - An `os_disk` block as documented below.

* `private_ip_address` - The Primary Private IP Address assigned to this Virtual Machine.

* `private_ip_addresses` - A list of Private IP Addresses assigned to this Virtual Machine.
Expand All @@ -413,6 +415,12 @@ An `identity` block exports the following:

* `tenant_id` - The Tenant ID associated with this Managed Service Identity.

---

An `os_disk` block exports the following:

* `id` - The ID of the OS disk.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions:
Expand Down