Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmss - support specifying ultra_ssd_disk_iops_read_write and ultra_ssd_disk_mbps_read_write for PremiumV2_LRS #21530

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
)

func TestAccLinuxVirtualMachineScaleSet_disksDataDiskBasic(t *testing.T) {
Expand Down Expand Up @@ -243,6 +244,55 @@ 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"),
})
}

// TODO Remove TestAccLinuxVirtualMachineScaleSet_disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPSLegacy in 4.0
func TestAccLinuxVirtualMachineScaleSet_disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPSLegacy(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("Skipping as property `ultra_ssd_disk_iops_read_write` and `ultra_ssd_disk_mbps_read_write` are deprecated in 4.0")
}

data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test")
r := LinuxVirtualMachineScaleSetResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPSLegacy(data, 3001, 126),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("admin_password"),
{
Config: r.disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPSLegacy(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{}
Expand Down Expand Up @@ -817,6 +867,115 @@ 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
disk_iops_read_write = %d
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)
}

// TODO Remove disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPSLegacy in 4.0
func (r LinuxVirtualMachineScaleSetResource) disksDataDiskStorageAccountTypePremiumV2LRSWithIOPSAndMBPSLegacy(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
Expand Down Expand Up @@ -899,11 +1058,11 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" {
}

data_disk {
storage_account_type = "UltraSSD_LRS"
caching = "None"
disk_size_gb = 10
lun = 10
ultra_ssd_disk_iops_read_write = 101
storage_account_type = "UltraSSD_LRS"
caching = "None"
disk_size_gb = 10
lun = 10
disk_iops_read_write = 101
}

additional_capabilities {
Expand Down Expand Up @@ -953,11 +1112,11 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" {
}

data_disk {
storage_account_type = "UltraSSD_LRS"
caching = "None"
disk_size_gb = 10
lun = 10
ultra_ssd_disk_mbps_read_write = 11
storage_account_type = "UltraSSD_LRS"
caching = "None"
disk_size_gb = 10
lun = 10
disk_mbps_read_write = 11
}

additional_capabilities {
Expand Down Expand Up @@ -1007,12 +1166,12 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" {
}

data_disk {
storage_account_type = "UltraSSD_LRS"
caching = "None"
disk_size_gb = 10
lun = 10
ultra_ssd_disk_iops_read_write = 101
ultra_ssd_disk_mbps_read_write = 11
storage_account_type = "UltraSSD_LRS"
caching = "None"
disk_size_gb = 10
lun = 10
disk_iops_read_write = 101
disk_mbps_read_write = 11
}

additional_capabilities {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func resourceLinuxVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, meta i

dataDisksRaw := d.Get("data_disk").([]interface{})
ultraSSDEnabled := d.Get("additional_capabilities.0.ultra_ssd_enabled").(bool)
dataDisks, err := ExpandVirtualMachineScaleSetDataDisk(dataDisksRaw, ultraSSDEnabled)
dataDisks, err := ExpandVirtualMachineScaleSetDataDisk(d, dataDisksRaw, ultraSSDEnabled)
if err != nil {
return fmt.Errorf("expanding `data_disk`: %+v", err)
}
Expand Down Expand Up @@ -612,7 +612,7 @@ func resourceLinuxVirtualMachineScaleSetUpdate(d *pluginsdk.ResourceData, meta i

if d.HasChange("data_disk") {
ultraSSDEnabled := d.Get("additional_capabilities.0.ultra_ssd_enabled").(bool)
dataDisks, err := ExpandVirtualMachineScaleSetDataDisk(d.Get("data_disk").([]interface{}), ultraSSDEnabled)
dataDisks, err := ExpandVirtualMachineScaleSetDataDisk(d, d.Get("data_disk").([]interface{}), ultraSSDEnabled)
if err != nil {
return fmt.Errorf("expanding `data_disk`: %+v", err)
}
Expand Down
Loading