From 7707160d41ac18ed93f30c86a378b905bf1c3795 Mon Sep 17 00:00:00 2001 From: Henry Buckle Date: Sat, 2 May 2020 11:37:07 +0100 Subject: [PATCH] support create option --- .../services/compute/virtual_machine_scale_set.go | 15 ++++++++++++--- .../linux_virtual_machine_scale_set.html.markdown | 2 ++ ...indows_virtual_machine_scale_set.html.markdown | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/azurerm/internal/services/compute/virtual_machine_scale_set.go b/azurerm/internal/services/compute/virtual_machine_scale_set.go index 617c3b05bc14..11eb1b0b283f 100644 --- a/azurerm/internal/services/compute/virtual_machine_scale_set.go +++ b/azurerm/internal/services/compute/virtual_machine_scale_set.go @@ -730,6 +730,16 @@ func VirtualMachineScaleSetDataDiskSchema() *schema.Schema { }, false), }, + "create_option": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + string(compute.DiskCreateOptionTypesEmpty), + string(compute.DiskCreateOptionTypesFromImage), + }, false), + Default: string(compute.DiskCreateOptionTypesEmpty), + }, + "disk_encryption_set_id": { Type: schema.TypeString, Optional: true, @@ -787,9 +797,7 @@ func ExpandVirtualMachineScaleSetDataDisk(input []interface{}) *[]compute.Virtua StorageAccountType: compute.StorageAccountTypes(raw["storage_account_type"].(string)), }, WriteAcceleratorEnabled: utils.Bool(raw["write_accelerator_enabled"].(bool)), - - // AFAIK this is required to be Empty - CreateOption: compute.DiskCreateOptionTypesEmpty, + CreateOption: compute.DiskCreateOptionTypes(raw["create_option"].(string)), } if id := raw["disk_encryption_set_id"].(string); id != "" { @@ -838,6 +846,7 @@ func FlattenVirtualMachineScaleSetDataDisk(input *[]compute.VirtualMachineScaleS output = append(output, map[string]interface{}{ "caching": string(v.Caching), + "create_option": string(v.CreateOption), "lun": lun, "disk_encryption_set_id": diskEncryptionSetId, "disk_size_gb": diskSizeGb, diff --git a/website/docs/r/linux_virtual_machine_scale_set.html.markdown b/website/docs/r/linux_virtual_machine_scale_set.html.markdown index 7ec83988addd..0e0d5bacf3af 100644 --- a/website/docs/r/linux_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/linux_virtual_machine_scale_set.html.markdown @@ -246,6 +246,8 @@ A `data_disk` block supports the following: * `caching` - (Required) The type of Caching which should be used for this Data Disk. Possible values are `None`, `ReadOnly` and `ReadWrite`. +* `create_option` - (Optional) The create option which should be used for this Data Disk. Possible values are `Empty` and `FromImage`. Defaults to `Empty`. (`FromImage` should only be used if the source image includes data disks). + * `disk_size_gb` - (Required) The size of the Data Disk which should be created. * `lun` - (Required) The Logical Unit Number of the Data Disk, which must be unique within the Virtual Machine. diff --git a/website/docs/r/windows_virtual_machine_scale_set.html.markdown b/website/docs/r/windows_virtual_machine_scale_set.html.markdown index 4911dd804da5..654f0f89e004 100644 --- a/website/docs/r/windows_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/windows_virtual_machine_scale_set.html.markdown @@ -238,6 +238,8 @@ A `data_disk` block supports the following: * `caching` - (Required) The type of Caching which should be used for this Data Disk. Possible values are `None`, `ReadOnly` and `ReadWrite`. +* `create_option` - (Optional) The create option which should be used for this Data Disk. Possible values are `Empty` and `FromImage`. Defaults to `Empty`. (`FromImage` should only be used if the source image includes data disks). + * `disk_size_gb` - (Required) The size of the Data Disk which should be created. * `lun` - (Required) The Logical Unit Number of the Data Disk, which must be unique within the Virtual Machine.