diff --git a/internal/services/compute/linux_virtual_machine_scale_set_disk_data_resource_test.go b/internal/services/compute/linux_virtual_machine_scale_set_disk_data_resource_test.go index b52bd4f04252..17a71fdee12a 100644 --- a/internal/services/compute/linux_virtual_machine_scale_set_disk_data_resource_test.go +++ b/internal/services/compute/linux_virtual_machine_scale_set_disk_data_resource_test.go @@ -243,6 +243,28 @@ func TestAccLinuxVirtualMachineScaleSet_disksDataDiskStorageAccountTypePremiumV2 }) } +func TestAccLinuxVirtualMachineScaleSet_disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPS(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test") + r := LinuxVirtualMachineScaleSetResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPS(data, 3001, 126), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("admin_password"), + { + Config: r.disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPS(data, 3002, 127), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("admin_password"), + }) +} + func TestAccLinuxVirtualMachineScaleSet_disksDataDiskStorageAccountTypePremiumZRS(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test") r := LinuxVirtualMachineScaleSetResource{} @@ -817,6 +839,60 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" { `, r.template(data), data.RandomInteger) } +func (r LinuxVirtualMachineScaleSetResource) disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPS(data acceptance.TestData, iops int, mbps int) string { + // Limited regional availability for `PremiumV2_LRS` + // `PremiumV2_LRS` disks can only be can only be attached to zonal VMs currently + data.Locations.Primary = "westeurope" + return fmt.Sprintf(` +%s + +resource "azurerm_linux_virtual_machine_scale_set" "test" { + name = "acctestvmss-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku = "Standard_F2s_v2" + instances = 1 + admin_username = "adminuser" + admin_password = "P@ssword1234!" + zones = ["1"] + + disable_password_authentication = false + + source_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "16.04-LTS" + version = "latest" + } + + os_disk { + storage_account_type = "Standard_LRS" + caching = "ReadWrite" + } + + data_disk { + storage_account_type = "PremiumV2_LRS" + caching = "None" + disk_size_gb = 10 + lun = 10 + ultra_ssd_disk_iops_read_write = %d + ultra_ssd_disk_mbps_read_write = %d + } + + network_interface { + name = "example" + primary = true + + ip_configuration { + name = "internal" + primary = true + subnet_id = azurerm_subnet.test.id + } + } +} +`, r.template(data), data.RandomInteger, iops, mbps) +} + func (r LinuxVirtualMachineScaleSetResource) disksDataDiskStorageAccountTypeUltraSSDLRS(data acceptance.TestData) string { return fmt.Sprintf(` %s diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set.go b/internal/services/compute/orchestrated_virtual_machine_scale_set.go index 0a1bba2a1ba5..156f5ce2d62c 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set.go @@ -549,16 +549,21 @@ func OrchestratedVirtualMachineScaleSetDataDiskSchema() *pluginsdk.Schema { Optional: true, Default: false, }, + + // TODO rename `ultra_ssd_disk_iops_read_write` to `disk_iops_read_write` in 4.0 "ultra_ssd_disk_iops_read_write": { - Type: pluginsdk.TypeInt, - Optional: true, - Computed: true, + Type: pluginsdk.TypeInt, + Optional: true, + ValidateFunc: validation.IntAtLeast(1), + Computed: true, }, + // TODO rename `ultra_ssd_disk_mbps_read_write` to `disk_mbps_read_write` in 4.0 "ultra_ssd_disk_mbps_read_write": { - Type: pluginsdk.TypeInt, - Optional: true, - Computed: true, + Type: pluginsdk.TypeInt, + Optional: true, + ValidateFunc: validation.IntAtLeast(1), + Computed: true, }, }, }, @@ -1260,12 +1265,13 @@ func ExpandOrchestratedVirtualMachineScaleSetDataDisk(input []interface{}, ultra for _, v := range input { raw := v.(map[string]interface{}) + storageAccountType := compute.StorageAccountTypes(raw["storage_account_type"].(string)) disk := compute.VirtualMachineScaleSetDataDisk{ Caching: compute.CachingTypes(raw["caching"].(string)), DiskSizeGB: utils.Int32(int32(raw["disk_size_gb"].(int))), Lun: utils.Int32(int32(raw["lun"].(int))), ManagedDisk: &compute.VirtualMachineScaleSetManagedDiskParameters{ - StorageAccountType: compute.StorageAccountTypes(raw["storage_account_type"].(string)), + StorageAccountType: storageAccountType, }, WriteAcceleratorEnabled: utils.Bool(raw["write_accelerator_enabled"].(bool)), CreateOption: compute.DiskCreateOptionTypes(raw["create_option"].(string)), @@ -1278,13 +1284,12 @@ func ExpandOrchestratedVirtualMachineScaleSetDataDisk(input []interface{}, ultra } var iops int - if diskIops, ok := raw["disk_iops_read_write"]; ok && diskIops.(int) > 0 { + if diskIops, ok := raw["ultra_ssd_disk_iops_read_write"]; ok && diskIops.(int) > 0 { iops = diskIops.(int) - } else if ssdIops, ok := raw["ultra_ssd_disk_iops_read_write"]; ok && ssdIops.(int) > 0 { - iops = ssdIops.(int) } - if iops > 0 && !ultraSSDEnabled { - return nil, fmt.Errorf("disk_iops_read_write and ultra_ssd_disk_iops_read_write are only available for UltraSSD disks") + + if iops > 0 && !ultraSSDEnabled && storageAccountType != compute.StorageAccountTypesPremiumV2LRS { + return nil, fmt.Errorf("`ultra_ssd_disk_iops_read_write` can only be set when `storage_account_type` is set to `PremiumV2_LRS` or `UltraSSD_LRS`") } // Do not set value unless value is greater than 0 - issue 15516 @@ -1293,13 +1298,12 @@ func ExpandOrchestratedVirtualMachineScaleSetDataDisk(input []interface{}, ultra } var mbps int - if diskMbps, ok := raw["disk_mbps_read_write"]; ok && diskMbps.(int) > 0 { + if diskMbps, ok := raw["ultra_ssd_disk_mbps_read_write"]; ok && diskMbps.(int) > 0 { mbps = diskMbps.(int) - } else if ssdMbps, ok := raw["ultra_ssd_disk_mbps_read_write"]; ok && ssdMbps.(int) > 0 { - mbps = ssdMbps.(int) } - if mbps > 0 && !ultraSSDEnabled { - return nil, fmt.Errorf("disk_mbps_read_write and ultra_ssd_disk_mbps_read_write are only available for UltraSSD disks") + + if mbps > 0 && !ultraSSDEnabled && storageAccountType != compute.StorageAccountTypesPremiumV2LRS { + return nil, fmt.Errorf("`ultra_ssd_disk_mbps_read_write` can only be set when `storage_account_type` is set to `PremiumV2_LRS` or `UltraSSD_LRS`") } // Do not set value unless value is greater than 0 - issue 15516 diff --git a/internal/services/compute/virtual_machine_scale_set.go b/internal/services/compute/virtual_machine_scale_set.go index 54e4095bfa4d..dab98c216430 100644 --- a/internal/services/compute/virtual_machine_scale_set.go +++ b/internal/services/compute/virtual_machine_scale_set.go @@ -1329,16 +1329,20 @@ func VirtualMachineScaleSetDataDiskSchema() *pluginsdk.Schema { Default: false, }, + // TODO rename `ultra_ssd_disk_iops_read_write` to `disk_iops_read_write` in 4.0 "ultra_ssd_disk_iops_read_write": { - Type: pluginsdk.TypeInt, - Optional: true, - Computed: true, + Type: pluginsdk.TypeInt, + Optional: true, + ValidateFunc: validation.IntAtLeast(1), + Computed: true, }, + // TODO rename `ultra_ssd_disk_mbps_read_write` to `disk_mbps_read_write` in 4.0 "ultra_ssd_disk_mbps_read_write": { - Type: pluginsdk.TypeInt, - Optional: true, - Computed: true, + Type: pluginsdk.TypeInt, + Optional: true, + ValidateFunc: validation.IntAtLeast(1), + Computed: true, }, }, }, @@ -1351,12 +1355,13 @@ func ExpandVirtualMachineScaleSetDataDisk(input []interface{}, ultraSSDEnabled b for _, v := range input { raw := v.(map[string]interface{}) + storageAccountType := compute.StorageAccountTypes(raw["storage_account_type"].(string)) disk := compute.VirtualMachineScaleSetDataDisk{ Caching: compute.CachingTypes(raw["caching"].(string)), DiskSizeGB: utils.Int32(int32(raw["disk_size_gb"].(int))), Lun: utils.Int32(int32(raw["lun"].(int))), ManagedDisk: &compute.VirtualMachineScaleSetManagedDiskParameters{ - StorageAccountType: compute.StorageAccountTypes(raw["storage_account_type"].(string)), + StorageAccountType: storageAccountType, }, WriteAcceleratorEnabled: utils.Bool(raw["write_accelerator_enabled"].(bool)), CreateOption: compute.DiskCreateOptionTypes(raw["create_option"].(string)), @@ -1373,25 +1378,21 @@ func ExpandVirtualMachineScaleSetDataDisk(input []interface{}, ultraSSDEnabled b } var iops int - if diskIops, ok := raw["disk_iops_read_write"]; ok && diskIops.(int) > 0 { + if diskIops, ok := raw["ultra_ssd_disk_iops_read_write"]; ok && diskIops.(int) > 0 { iops = diskIops.(int) - } else if ssdIops, ok := raw["ultra_ssd_disk_iops_read_write"]; ok && ssdIops.(int) > 0 { - iops = ssdIops.(int) } - if iops > 0 && !ultraSSDEnabled { - return nil, fmt.Errorf("disk_iops_read_write and ultra_ssd_disk_iops_read_write are only available for UltraSSD disks") + if iops > 0 && !ultraSSDEnabled && storageAccountType != compute.StorageAccountTypesPremiumV2LRS { + return nil, fmt.Errorf("`ultra_ssd_disk_iops_read_write` can only be set when `storage_account_type` is set to `PremiumV2_LRS` or `UltraSSD_LRS`") } var mbps int - if diskMbps, ok := raw["disk_mbps_read_write"]; ok && diskMbps.(int) > 0 { + if diskMbps, ok := raw["ultra_ssd_disk_mbps_read_write"]; ok && diskMbps.(int) > 0 { mbps = diskMbps.(int) - } else if ssdMbps, ok := raw["ultra_ssd_disk_mbps_read_write"]; ok && ssdMbps.(int) > 0 { - mbps = ssdMbps.(int) } - if mbps > 0 && !ultraSSDEnabled { - return nil, fmt.Errorf("disk_mbps_read_write and ultra_ssd_disk_mbps_read_write are only available for UltraSSD disks") + if mbps > 0 && !ultraSSDEnabled && storageAccountType != compute.StorageAccountTypesPremiumV2LRS { + return nil, fmt.Errorf("`ultra_ssd_disk_mbps_read_write` can only be set when `storage_account_type` is set to `PremiumV2_LRS` or `UltraSSD_LRS`") } // Do not set value unless value is greater than 0 - issue 15516 diff --git a/internal/services/compute/windows_virtual_machine_scale_set_disk_data_resource_test.go b/internal/services/compute/windows_virtual_machine_scale_set_disk_data_resource_test.go index 7a8522f39555..c8d225a96286 100644 --- a/internal/services/compute/windows_virtual_machine_scale_set_disk_data_resource_test.go +++ b/internal/services/compute/windows_virtual_machine_scale_set_disk_data_resource_test.go @@ -243,6 +243,28 @@ func TestAccWindowsVirtualMachineScaleSet_disksDataDiskStorageAccountTypePremium }) } +func TestAccWindowsVirtualMachineScaleSet_disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPS(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine_scale_set", "test") + r := WindowsVirtualMachineScaleSetResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPS(data, 3001, 126), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("admin_password"), + { + Config: r.disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPS(data, 3002, 127), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("admin_password"), + }) +} + func TestAccWindowsVirtualMachineScaleSet_disksDataDiskStorageAccountTypePremiumZRS(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_windows_virtual_machine_scale_set", "test") r := WindowsVirtualMachineScaleSetResource{} @@ -808,6 +830,57 @@ resource "azurerm_windows_virtual_machine_scale_set" "test" { `, r.template(data)) } +func (r WindowsVirtualMachineScaleSetResource) disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPS(data acceptance.TestData, iops int, mbps int) string { + // Limited regional availability for `PremiumV2_LRS` + data.Locations.Primary = "westeurope" + return fmt.Sprintf(` +%s + +resource "azurerm_windows_virtual_machine_scale_set" "test" { + name = local.vm_name + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku = "Standard_F2s_v2" + instances = 1 + admin_username = "adminuser" + admin_password = "P@ssword1234!" + zones = ["1"] + + source_image_reference { + publisher = "MicrosoftWindowsServer" + offer = "WindowsServer" + sku = "2019-Datacenter" + version = "latest" + } + + os_disk { + storage_account_type = "Standard_LRS" + caching = "ReadWrite" + } + + data_disk { + storage_account_type = "PremiumV2_LRS" + caching = "None" + disk_size_gb = 10 + lun = 10 + ultra_ssd_disk_iops_read_write = %d + ultra_ssd_disk_mbps_read_write = %d + } + + network_interface { + name = "example" + primary = true + + ip_configuration { + name = "internal" + primary = true + subnet_id = azurerm_subnet.test.id + } + } +} +`, r.template(data), iops, mbps) +} + func (r WindowsVirtualMachineScaleSetResource) disksDataDiskStorageAccountTypeUltraSSDLRS(data acceptance.TestData) string { return fmt.Sprintf(` %s 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 841fd4dda65c..db2fb59ab612 100644 --- a/website/docs/r/linux_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/linux_virtual_machine_scale_set.html.markdown @@ -310,9 +310,9 @@ A `data_disk` block supports the following: -> **NOTE:** Disk Encryption Sets are in Public Preview in a limited set of regions -* `ultra_ssd_disk_iops_read_write` - (Optional) Specifies the Read-Write IOPS for this Data Disk. Only settable for UltraSSD disks. +* `ultra_ssd_disk_iops_read_write` - (Optional) Specifies the Read-Write IOPS for this Data Disk. Only settable when `storage_account_type` is `PremiumV2_LRS` or `UltraSSD_LRS`. -* `ultra_ssd_disk_mbps_read_write` - (Optional) Specifies the bandwidth in MB per second for this Data Disk. Only settable for UltraSSD disks. +* `ultra_ssd_disk_mbps_read_write` - (Optional) Specifies the bandwidth in MB per second for this Data Disk. Only settable when `storage_account_type` is `PremiumV2_LRS` or `UltraSSD_LRS`. * `write_accelerator_enabled` - (Optional) Should Write Accelerator be enabled for this Data Disk? Defaults to `false`. diff --git a/website/docs/r/orchestrated_virtual_machine_scale_set.html.markdown b/website/docs/r/orchestrated_virtual_machine_scale_set.html.markdown index 28f5c0189b6d..906d1101d1b8 100644 --- a/website/docs/r/orchestrated_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/orchestrated_virtual_machine_scale_set.html.markdown @@ -291,9 +291,9 @@ A `data_disk` block supports the following: * `disk_encryption_set_id` - (Optional) The ID of the Disk Encryption Set which should be used to encrypt the Data Disk. Changing this forces a new resource to be created. -* `ultra_ssd_disk_iops_read_write` - (Optional) Specifies the Read-Write IOPS for this Data Disk. Only settable for UltraSSD disks. +* `ultra_disk_iops_read_write` - (Optional) Specifies the Read-Write IOPS for this Data Disk. Only settable when `storage_account_type` is `PremiumV2_LRS` or `UltraSSD_LRS`. -* `ultra_ssd_disk_mbps_read_write` - (Optional) Specifies the bandwidth in MB per second for this Data Disk. Only settable for UltraSSD disks. +* `ultra_disk_mbps_read_write` - (Optional) Specifies the bandwidth in MB per second for this Data Disk. Only settable when `storage_account_type` is `PremiumV2_LRS` or `UltraSSD_LRS`. * `write_accelerator_enabled` - (Optional) Specifies if Write Accelerator is enabled on the Data Disk. Defaults to `false`. 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 88bc7ca6539e..e94d26bbb64a 100644 --- a/website/docs/r/windows_virtual_machine_scale_set.html.markdown +++ b/website/docs/r/windows_virtual_machine_scale_set.html.markdown @@ -298,9 +298,9 @@ A `data_disk` block supports the following: -> **NOTE:** Disk Encryption Sets are in Public Preview in a limited set of regions -* `ultra_ssd_disk_iops_read_write` - (Optional) Specifies the Read-Write IOPS for this Data Disk. Only settable for UltraSSD disks. +* `ultra_ssd_disk_iops_read_write` - (Optional) Specifies the Read-Write IOPS for this Data Disk. Only settable when `storage_account_type` is `PremiumV2_LRS` or `UltraSSD_LRS`. -* `ultra_ssd_disk_mbps_read_write` - (Optional) Specifies the bandwidth in MB per second for this Data Disk. Only settable for UltraSSD disks. +* `ultra_ssd_disk_mbps_read_write` - (Optional) Specifies the bandwidth in MB per second for this Data Disk. Only settable when `storage_account_type` is `PremiumV2_LRS` or `UltraSSD_LRS`. * `write_accelerator_enabled` - (Optional) Should Write Accelerator be enabled for this Data Disk? Defaults to `false`.