From 33738821923b0c0d3d191f24177c9d398a0f5cbc Mon Sep 17 00:00:00 2001 From: Iryna Bryndzei <17791746+ira-bryndzei@users.noreply.github.com> Date: Wed, 12 Sep 2018 17:58:46 +0300 Subject: [PATCH] VM/VMSS: support for `StandardSSD_LRS` managed disk type (#1901) * added support for StorageAccountTypesStandardSSDLRS * delete failed test block * Documenting the new `StandardSSD_LRS` type * Adding tests for VM/VMSS for the new StandardSSD_LRS type --- azurerm/resource_arm_managed_disk.go | 6 +- azurerm/resource_arm_managed_disk_test.go | 4 +- azurerm/resource_arm_virtual_machine.go | 10 +- ..._arm_virtual_machine_managed_disks_test.go | 94 +++++++++++++++ .../resource_arm_virtual_machine_scale_set.go | 10 +- ...urce_arm_virtual_machine_scale_set_test.go | 110 ++++++++++++++++++ website/docs/r/virtual_machine.html.markdown | 4 +- .../r/virtual_machine_scale_set.html.markdown | 4 +- 8 files changed, 226 insertions(+), 16 deletions(-) diff --git a/azurerm/resource_arm_managed_disk.go b/azurerm/resource_arm_managed_disk.go index 5db396cd7193..9449f83474f6 100644 --- a/azurerm/resource_arm_managed_disk.go +++ b/azurerm/resource_arm_managed_disk.go @@ -41,6 +41,7 @@ func resourceArmManagedDisk() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{ string(compute.StorageAccountTypesStandardLRS), string(compute.StorageAccountTypesPremiumLRS), + string(compute.StorageAccountTypesStandardSSDLRS), }, true), DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, @@ -124,11 +125,12 @@ func resourceArmManagedDiskCreate(d *schema.ResourceData, meta interface{}) erro zones := expandZones(d.Get("zones").([]interface{})) var skuName compute.StorageAccountTypes - // TODO: support for the StandardSSD if strings.EqualFold(storageAccountType, string(compute.StorageAccountTypesPremiumLRS)) { skuName = compute.StorageAccountTypesPremiumLRS - } else { + } else if strings.EqualFold(storageAccountType, string(compute.StorageAccountTypesStandardLRS)) { skuName = compute.StorageAccountTypesStandardLRS + } else if strings.EqualFold(storageAccountType, string(compute.StorageAccountTypesStandardSSDLRS)) { + skuName = compute.StorageAccountTypesStandardSSDLRS } createDisk := compute.Disk{ diff --git a/azurerm/resource_arm_managed_disk_test.go b/azurerm/resource_arm_managed_disk_test.go index 74f1bb63d58a..091f45ded2f9 100644 --- a/azurerm/resource_arm_managed_disk_test.go +++ b/azurerm/resource_arm_managed_disk_test.go @@ -139,7 +139,7 @@ func TestAccAzureRMManagedDisk_update(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.environment", "acctest"), resource.TestCheckResourceAttr(resourceName, "tags.cost-center", "ops"), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "1"), - resource.TestCheckResourceAttr(resourceName, "storage_account_type", string(compute.StandardLRS)), + resource.TestCheckResourceAttr(resourceName, "storage_account_type", string(compute.StorageAccountTypesStandardLRS)), ), }, { @@ -149,7 +149,7 @@ func TestAccAzureRMManagedDisk_update(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.environment", "acctest"), resource.TestCheckResourceAttr(resourceName, "disk_size_gb", "2"), - resource.TestCheckResourceAttr(resourceName, "storage_account_type", string(compute.PremiumLRS)), + resource.TestCheckResourceAttr(resourceName, "storage_account_type", string(compute.StorageAccountTypesPremiumLRS)), ), }, }, diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go index 66989c91ca63..88adab6971be 100644 --- a/azurerm/resource_arm_virtual_machine.go +++ b/azurerm/resource_arm_virtual_machine.go @@ -213,8 +213,9 @@ func resourceArmVirtualMachine() *schema.Resource { Computed: true, ConflictsWith: []string{"storage_os_disk.0.vhd_uri"}, ValidateFunc: validation.StringInSlice([]string{ - string(compute.PremiumLRS), - string(compute.StandardLRS), + string(compute.StorageAccountTypesPremiumLRS), + string(compute.StorageAccountTypesStandardLRS), + string(compute.StorageAccountTypesStandardSSDLRS), }, true), }, @@ -285,8 +286,9 @@ func resourceArmVirtualMachine() *schema.Resource { Optional: true, Computed: true, ValidateFunc: validation.StringInSlice([]string{ - string(compute.PremiumLRS), - string(compute.StandardLRS), + string(compute.StorageAccountTypesPremiumLRS), + string(compute.StorageAccountTypesStandardLRS), + string(compute.StorageAccountTypesStandardSSDLRS), }, true), }, diff --git a/azurerm/resource_arm_virtual_machine_managed_disks_test.go b/azurerm/resource_arm_virtual_machine_managed_disks_test.go index dbf2d6daf3a3..b300df8b3931 100644 --- a/azurerm/resource_arm_virtual_machine_managed_disks_test.go +++ b/azurerm/resource_arm_virtual_machine_managed_disks_test.go @@ -16,6 +16,27 @@ import ( // NOTE: Test `TestAccAzureRMVirtualMachine_enableAnWithVM` requires a machine of size `D8_v3` which is large/expensive - you may wish to ignore this test" +func TestAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_standardSSD(t *testing.T) { + resourceName := "azurerm_virtual_machine.test" + var vm compute.VirtualMachine + ri := acctest.RandInt() + config := testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_standardSSD(ri, testLocation()) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMVirtualMachineDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMVirtualMachineExists(resourceName, &vm), + resource.TestCheckResourceAttr(resourceName, "storage_os_disk.0.managed_disk_type", "StandardSSD_LRS"), + ), + }, + }, + }) +} + func TestAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_explicit(t *testing.T) { var vm compute.VirtualMachine ri := acctest.RandInt() @@ -1040,6 +1061,79 @@ resource "azurerm_virtual_machine" "test" { `, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt) } +func testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_standardSSD(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctvn-%d" + address_space = ["10.0.0.0/16"] + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_subnet" "test" { + name = "acctsub-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.2.0/24" +} + +resource "azurerm_network_interface" "test" { + name = "acctni-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + ip_configuration { + name = "testconfiguration1" + subnet_id = "${azurerm_subnet.test.id}" + private_ip_address_allocation = "dynamic" + } +} + +resource "azurerm_virtual_machine" "test" { + name = "acctvm-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + network_interface_ids = ["${azurerm_network_interface.test.id}"] + vm_size = "Standard_D1_v2" + + storage_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "16.04-LTS" + version = "latest" + } + + storage_os_disk { + name = "osd-%d" + caching = "ReadWrite" + create_option = "FromImage" + disk_size_gb = "50" + managed_disk_type = "StandardSSD_LRS" + } + + os_profile { + computer_name = "hn%d" + admin_username = "testadmin" + admin_password = "Password1234!" + } + + os_profile_linux_config { + disable_password_authentication = false + } + + tags { + environment = "Production" + cost-center = "Ops" + } +} +`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt) +} + func testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_implicit(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index 17106a18ef6c..bcd153f3226b 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -479,8 +479,9 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { Computed: true, ConflictsWith: []string{"storage_profile_os_disk.vhd_containers"}, ValidateFunc: validation.StringInSlice([]string{ - string(compute.PremiumLRS), - string(compute.StandardLRS), + string(compute.StorageAccountTypesPremiumLRS), + string(compute.StorageAccountTypesStandardLRS), + string(compute.StorageAccountTypesStandardSSDLRS), }, true), }, @@ -537,8 +538,9 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { Optional: true, Computed: true, ValidateFunc: validation.StringInSlice([]string{ - string(compute.PremiumLRS), - string(compute.StandardLRS), + string(compute.StorageAccountTypesPremiumLRS), + string(compute.StorageAccountTypesStandardLRS), + string(compute.StorageAccountTypesStandardSSDLRS), }, true), }, }, diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index c53f6e6973e1..ef5092302b93 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -39,6 +39,31 @@ func TestAccAzureRMVirtualMachineScaleSet_basic(t *testing.T) { }) } +func TestAccAzureRMVirtualMachineScaleSet_standardSSD(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" + ri := acctest.RandInt() + config := testAccAzureRMVirtualMachineScaleSet_standardSSD(ri, testLocation()) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"os_profile.0.admin_password"}, + }, + }, + }) +} + func TestAccAzureRMVirtualMachineScaleSet_basicPublicIP(t *testing.T) { resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() @@ -1160,6 +1185,91 @@ resource "azurerm_virtual_machine_scale_set" "test" { `, rInt, location) } +func testAccAzureRMVirtualMachineScaleSet_standardSSD(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctvn-%[1]d" + address_space = ["10.0.0.0/16"] + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_subnet" "test" { + name = "acctsub-%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.2.0/24" +} + +resource "azurerm_storage_account" "test" { + name = "accsa%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_tier = "Standard" + account_replication_type = "LRS" + + tags { + environment = "staging" + } +} + +resource "azurerm_storage_container" "test" { + name = "vhds" + resource_group_name = "${azurerm_resource_group.test.name}" + storage_account_name = "${azurerm_storage_account.test.name}" + container_access_type = "private" +} + +resource "azurerm_virtual_machine_scale_set" "test" { + name = "acctvmss-%[1]d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + upgrade_policy_mode = "Manual" + single_placement_group = false + + sku { + name = "Standard_D1_v2" + tier = "Standard" + capacity = 2 + } + + os_profile { + computer_name_prefix = "testvm-%[1]d" + admin_username = "myadmin" + admin_password = "Passwword1234" + } + + network_profile { + name = "TestNetworkProfile-%[1]d" + primary = true + ip_configuration { + name = "TestIPConfiguration" + subnet_id = "${azurerm_subnet.test.id}" + } + } + + storage_profile_os_disk { + name = "" + caching = "ReadWrite" + create_option = "FromImage" + managed_disk_type = "StandardSSD_LRS" + } + + storage_profile_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "16.04-LTS" + version = "latest" + } +} +`, rInt, location) +} + func testAccAzureRMVirtualMachineScaleSet_basicPublicIP(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/website/docs/r/virtual_machine.html.markdown b/website/docs/r/virtual_machine.html.markdown index 838843edf1b3..1cc91d80126d 100644 --- a/website/docs/r/virtual_machine.html.markdown +++ b/website/docs/r/virtual_machine.html.markdown @@ -302,7 +302,7 @@ A `storage_data_disk` block supports the following: The following properties apply when using Managed Disks: -* `managed_disk_type` - (Optional) Specifies the type of managed disk to create. Possible values are either `Standard_LRS` or `Premium_LRS`. +* `managed_disk_type` - (Optional) Specifies the type of managed disk to create. Possible values are either `Standard_LRS`, `StandardSSD_LRS` or `Premium_LRS`. * `managed_disk_id` - (Optional) Specifies the ID of an Existing Managed Disk which should be attached to this Virtual Machine. When this field is set `create_option` must be set to `Attach`. @@ -332,7 +332,7 @@ The following properties apply when using Managed Disks: * `managed_disk_id` - (Optional) Specifies the ID of an existing Managed Disk which should be attached as the OS Disk of this Virtual Machine. If this is set then the `create_option` must be set to `Attach`. -* `managed_disk_type` - (Optional) Specifies the type of Managed Disk which should be created. Possible values are `Standard_LRS` or `Premium_LRS`. +* `managed_disk_type` - (Optional) Specifies the type of Managed Disk which should be created. Possible values are `Standard_LRS`, `StandardSSD_LRS` or `Premium_LRS`. The following properties apply when using Unmanaged Disks: diff --git a/website/docs/r/virtual_machine_scale_set.html.markdown b/website/docs/r/virtual_machine_scale_set.html.markdown index b656e4011f26..02c189f56d2e 100644 --- a/website/docs/r/virtual_machine_scale_set.html.markdown +++ b/website/docs/r/virtual_machine_scale_set.html.markdown @@ -388,7 +388,7 @@ output "principal_id" { * `name` - (Optional) Specifies the disk name. Must be specified when using unmanaged disk ('managed_disk_type' property not set). * `vhd_containers` - (Optional) Specifies the vhd uri. Cannot be used when `image` or `managed_disk_type` is specified. -* `managed_disk_type` - (Optional) Specifies the type of managed disk to create. Value you must be either `Standard_LRS` or `Premium_LRS`. Cannot be used when `vhd_containers` or `image` is specified. +* `managed_disk_type` - (Optional) Specifies the type of managed disk to create. Value you must be either `Standard_LRS`, `StandardSSD_LRS` or `Premium_LRS`. Cannot be used when `vhd_containers` or `image` is specified. * `create_option` - (Required) Specifies how the virtual machine should be created. The only possible option is `FromImage`. * `caching` - (Optional) Specifies the caching requirements. Possible values include: `None` (default), `ReadOnly`, `ReadWrite`. * `image` - (Optional) Specifies the blob uri for user image. A virtual machine scale set creates an os disk in the same container as the user image. @@ -402,7 +402,7 @@ output "principal_id" { * `create_option` - (Optional) Specifies how the data disk should be created. The only possible options are `FromImage` and `Empty`. * `caching` - (Optional) Specifies the caching requirements. Possible values include: `None` (default), `ReadOnly`, `ReadWrite`. * `disk_size_gb` - (Optional) Specifies the size of the disk in GB. This element is required when creating an empty disk. -* `managed_disk_type` - (Optional) Specifies the type of managed disk to create. Value must be either `Standard_LRS` or `Premium_LRS`. +* `managed_disk_type` - (Optional) Specifies the type of managed disk to create. Value must be either `Standard_LRS`, `StandardSSD_LRS` or `Premium_LRS`. `storage_profile_image_reference` supports the following: