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

azurerm_virtual_machine: add support for Ultra SSD's to the managed_disk_type property #3860

Merged
merged 21 commits into from
Sep 1, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
49 changes: 49 additions & 0 deletions azurerm/resource_arm_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ func resourceArmVirtualMachine() *schema.Resource {
string(compute.StorageAccountTypesPremiumLRS),
string(compute.StorageAccountTypesStandardLRS),
string(compute.StorageAccountTypesStandardSSDLRS),
string(compute.StorageAccountTypesUltraSSDLRS),
katbyte marked this conversation as resolved.
Show resolved Hide resolved
}, true),
},

Expand Down Expand Up @@ -356,6 +357,19 @@ func resourceArmVirtualMachine() *schema.Resource {
},
},
},
"additional_capabilities": {
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ultra_ssd_enabled": {
Type: schema.TypeBool,
Required: true,
katbyte marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
},

"os_profile": {
Type: schema.TypeSet,
Expand Down Expand Up @@ -630,6 +644,9 @@ func resourceArmVirtualMachineCreateUpdate(d *schema.ResourceData, meta interfac
properties.DiagnosticsProfile = diagnosticsProfile
}
}
if _, ok := d.GetOk("additional_capabilities"); ok {
properties.AdditionalCapabilities = expandAzureRmVirtualMachineAdditionalCapabilities(d)
}

if _, ok := d.GetOk("os_profile"); ok {
osProfile, err2 := expandAzureRmVirtualMachineOsProfile(d)
Expand Down Expand Up @@ -811,6 +828,11 @@ func resourceArmVirtualMachineRead(d *schema.ResourceData, meta interface{}) err
return fmt.Errorf("Error setting `boot_diagnostics`: %#v", err)
}
}
if profile := props.AdditionalCapabilities; profile != nil {
venkey1000 marked this conversation as resolved.
Show resolved Hide resolved
if err := d.Set("additional_capabilities", flattenAzureRmVirtualMachineAdditionalCapabilities(profile)); err != nil {
venkey1000 marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("Error setting `additional_capabilities`: %#v", err)
}
}

if profile := props.NetworkProfile; profile != nil {
if err := d.Set("network_interface_ids", flattenAzureRmVirtualMachineNetworkInterfaces(profile)); err != nil {
Expand Down Expand Up @@ -1091,6 +1113,19 @@ func flattenAzureRmVirtualMachineDiagnosticsProfile(profile *compute.BootDiagnos
return []interface{}{result}
}

func flattenAzureRmVirtualMachineAdditionalCapabilities(profile *compute.AdditionalCapabilities) []interface{} {
if profile == nil {
return []interface{}{}
}

result := make(map[string]interface{})

if profile.UltraSSDEnabled != nil {
result["ultra_ssd_enabled"] = *profile.UltraSSDEnabled
}
return []interface{}{result}
}

func flattenAzureRmVirtualMachineNetworkInterfaces(profile *compute.NetworkProfile) []interface{} {
result := make([]interface{}, 0)
for _, nic := range *profile.NetworkInterfaces {
Expand Down Expand Up @@ -1636,6 +1671,20 @@ func expandAzureRmVirtualMachineDiagnosticsProfile(d *schema.ResourceData) *comp
return nil
}

func expandAzureRmVirtualMachineAdditionalCapabilities(d *schema.ResourceData) *compute.AdditionalCapabilities {
additionalCapabilities := d.Get("additional_capabilities").([]interface{})
if len(additionalCapabilities) > 0 {
additionalCapability := additionalCapabilities[0].(map[string]interface{})

capability := &compute.AdditionalCapabilities{
UltraSSDEnabled: utils.Bool(additionalCapability["ultra_ssd_enabled"].(bool)),
}
return capability
}

return nil
}

func expandAzureRmVirtualMachineImageReference(d *schema.ResourceData) (*compute.ImageReference, error) {
storageImageRefs := d.Get("storage_image_reference").(*schema.Set).List()

Expand Down
10 changes: 9 additions & 1 deletion website/docs/r/virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ The following arguments are supported:

* `boot_diagnostics` - (Optional) A `boot_diagnostics` block.

* `additional_capabilities` - (Optional) A `additional_capabilities` block.

* `delete_os_disk_on_termination` - (Optional) Should the OS Disk (either the Managed Disk / VHD Blob) be deleted when the Virtual Machine is destroyed? Defaults to `false`.

* `delete_data_disks_on_termination` - (Optional) Should the Data Disks (either the Managed Disks / VHD Blobs) be deleted when the Virtual Machine is destroyed? Defaults to `false`.
Expand Down Expand Up @@ -172,6 +174,12 @@ A `boot_diagnostics` block supports the following:

---

A `additional_capabilities` block supports the following:
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved

* `ultra_ssd_enabled` - (Required) Should Ultra SSD disk be enabled for this Virtual Machine?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add the instructions someone needs to follow to enabled this on their subscription here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UltraSSD whitelisting is only a temporary measure since the feature is in preview.

Copy link
Collaborator

@katbyte katbyte Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THe docs should contain all information required for a user to use this feature, temporary or not.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katbyte Sure, we can go ahead and get this added
"Currently, ultra SSDs are in preview and you must enroll (https://aka.ms/UltraSSDPreviewSignUp) in the preview in order to access them."

One small problem though is that once this feature is GA, this doc would have to be updated again. Alternatively, we could update the above line and add that 'Once the feature is GA, enrolment would not be required to use this feature".

Also, got a confirmation that the subscription ID's you submitted have been whitelisted for UltraSSD. Can you please confirm if you are able to test now?

@venkey1000 Can you also add a reference the article
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/disks-enable-ultra-ssd


---

A `identity` block supports the following:

* `type` - (Required) The Managed Service Identity Type of this Virtual Machine. Possible values are `SystemAssigned` (where Azure will generate a Service Principal for you), `UserAssigned` (where you can specify the Service Principal ID's) to be used by this Virtual Machine using the `identity_ids` field, and `SystemAssigned, UserAssigned` which assigns both a system managed identity as well as the specified user assigned identities.
Expand Down Expand Up @@ -299,7 +307,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`, `StandardSSD_LRS` or `Premium_LRS`.
* `managed_disk_type` - (Optional) Specifies the type of managed disk to create. Possible values are either `Standard_LRS`, `StandardSSD_LRS`, `Premium_LRS` or `UltraSSD_LRS`.
katbyte marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down