Skip to content

Commit

Permalink
Added the write_accelerator_enabled property to azurerm_virtual_machi…
Browse files Browse the repository at this point in the history
…ne disks
  • Loading branch information
katbyte committed Mar 12, 2018
1 parent 3cd42a1 commit 0956eb2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
34 changes: 29 additions & 5 deletions azurerm/resource_arm_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ func resourceArmVirtualMachine() *schema.Resource {
Computed: true,
ValidateFunc: validateDiskSizeGB,
},

"write_accelerator_enabled": {
Type: schema.TypeBool,
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -293,6 +298,11 @@ func resourceArmVirtualMachine() *schema.Resource {
Type: schema.TypeInt,
Required: true,
},

"write_accelerator_enabled": {
Type: schema.TypeBool,
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -971,6 +981,10 @@ func flattenAzureRmVirtualMachineDataDisk(disks *[]compute.DataDisk) interface{}
}
l["lun"] = *disk.Lun

if v := disk.WriteAcceleratorEnabled; v != nil {
l["write_accelerator_enabled"] = *disk.WriteAcceleratorEnabled
}

result[i] = l
}
return result
Expand Down Expand Up @@ -1078,6 +1092,10 @@ func flattenAzureRmVirtualMachineOsDisk(disk *compute.OSDisk) []interface{} {
}
result["os_type"] = string(disk.OsType)

if v := disk.WriteAcceleratorEnabled; v != nil {
result["write_accelerator_enabled"] = *disk.WriteAcceleratorEnabled
}

return []interface{}{result}
}

Expand Down Expand Up @@ -1359,9 +1377,12 @@ func expandAzureRmVirtualMachineDataDisk(d *schema.ResourceData) ([]compute.Data
data_disk.Caching = compute.CachingTypes(v)
}

if v := config["disk_size_gb"]; v != nil {
diskSize := int32(config["disk_size_gb"].(int))
data_disk.DiskSizeGB = &diskSize
if v, ok := config["disk_size_gb"].(int); ok {
data_disk.DiskSizeGB = utils.Int32(int32(v))
}

if v, ok := config["write_accelerator_enabled"].(bool); ok {
data_disk.WriteAcceleratorEnabled = utils.Bool(v)
}

data_disks = append(data_disks, data_disk)
Expand Down Expand Up @@ -1508,8 +1529,11 @@ func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk,
}

if v := config["disk_size_gb"].(int); v != 0 {
diskSize := int32(v)
osDisk.DiskSizeGB = &diskSize
osDisk.DiskSizeGB = utils.Int32(int32(v))
}

if v, ok := config["write_accelerator_enabled"].(bool); ok {
osDisk.WriteAcceleratorEnabled = utils.Bool(v)
}

return osDisk, nil
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ resource "azurerm_virtual_machine" "test" {
* `image_uri` - (Optional) Specifies the image_uri in the form publisherName:offer:skus:version. `image_uri` can also specify the [VHD uri](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-cli-deploy-templates/#create-a-custom-vm-image) of a custom VM image to clone. When cloning a custom disk image the `os_type` documented below becomes required.
* `os_type` - (Optional) Specifies the operating system Type, valid values are windows, linux.
* `disk_size_gb` - (Optional) Specifies the size of the os disk in gigabytes.
* `write_accelerator_enabled` - (Optional) Specifies if Write Accelerator is enabled on the disk.

`storage_data_disk` supports the following:

Expand All @@ -423,6 +424,7 @@ resource "azurerm_virtual_machine" "test" {
* `disk_size_gb` - (Required) Specifies the size of the data disk in gigabytes.
* `caching` - (Optional) Specifies the caching requirements.
* `lun` - (Required) Specifies the logical unit number of the data disk.
* `write_accelerator_enabled` - (Optional) Specifies if Write Accelerator is enabled on the disk.

`os_profile` supports the following:

Expand Down

0 comments on commit 0956eb2

Please sign in to comment.