Skip to content

Commit 6dae2d1

Browse files
sreallymattNotTheEvilOne
authored andcommitted
azurerm_(windows|linux)_virtual_machine - adding os_disk ID attribute (hashicorp#28352)
* Add vm OS disk ID attribute * Update docs
1 parent fa4a910 commit 6dae2d1

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

internal/services/compute/virtual_machine.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ func virtualMachineOSDiskSchema() *pluginsdk.Schema {
227227
Optional: true,
228228
Default: false,
229229
},
230+
231+
"id": {
232+
Type: pluginsdk.TypeString,
233+
Computed: true,
234+
},
230235
},
231236
},
232237
}
@@ -327,6 +332,7 @@ func flattenVirtualMachineOSDisk(ctx context.Context, disksClient *disks.DisksCl
327332
storageAccountType := ""
328333
secureVMDiskEncryptionSetId := ""
329334
securityEncryptionType := ""
335+
osDiskId := ""
330336

331337
if input.ManagedDisk != nil {
332338
storageAccountType = string(pointer.From(input.ManagedDisk.StorageAccountType))
@@ -365,6 +371,8 @@ func flattenVirtualMachineOSDisk(ctx context.Context, disksClient *disks.DisksCl
365371
diskEncryptionSetId = *disk.Model.Properties.Encryption.DiskEncryptionSetId
366372
}
367373
}
374+
375+
osDiskId = id.ID()
368376
}
369377

370378
if securityProfile := input.ManagedDisk.SecurityProfile; securityProfile != nil {
@@ -382,9 +390,10 @@ func flattenVirtualMachineOSDisk(ctx context.Context, disksClient *disks.DisksCl
382390
return []interface{}{
383391
map[string]interface{}{
384392
"caching": string(pointer.From(input.Caching)),
385-
"disk_size_gb": diskSizeGb,
386393
"diff_disk_settings": diffDiskSettings,
387394
"disk_encryption_set_id": diskEncryptionSetId,
395+
"disk_size_gb": diskSizeGb,
396+
"id": osDiskId,
388397
"name": name,
389398
"storage_account_type": storageAccountType,
390399
"secure_vm_disk_encryption_set_id": secureVMDiskEncryptionSetId,

website/docs/r/linux_virtual_machine.html.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ In addition to the Arguments listed above - the following Attributes are exporte
386386

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

389+
* `os_disk` - An `os_disk` block as documented below.
390+
389391
* `private_ip_address` - The Primary Private IP Address assigned to this Virtual Machine.
390392

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

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

409+
---
410+
411+
An `os_disk` block exports the following:
412+
413+
* `id` - The ID of the OS disk.
414+
407415
## Timeouts
408416

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

website/docs/r/windows_virtual_machine.html.markdown

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ The following arguments are supported:
101101

102102
* `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.
103103

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

106106
* `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.
107107

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

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

398+
* `os_disk` - An `os_disk` block as documented below.
399+
398400
* `private_ip_address` - The Primary Private IP Address assigned to this Virtual Machine.
399401

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

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

418+
---
419+
420+
An `os_disk` block exports the following:
421+
422+
* `id` - The ID of the OS disk.
423+
416424
## Timeouts
417425

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

0 commit comments

Comments
 (0)