Skip to content

Commit

Permalink
provider/azurerm: add caching support for virtual_machine data_disks
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter McAtominey committed Jan 11, 2017
1 parent 6bafd4c commit 6b6a1c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions builtin/providers/azurerm/resource_arm_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ func resourceArmVirtualMachine() *schema.Resource {
Required: true,
},

"caching": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"disk_size_gb": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -864,6 +870,7 @@ func flattenAzureRmVirtualMachineDataDisk(disks *[]compute.DataDisk) interface{}
l["name"] = *disk.Name
l["vhd_uri"] = *disk.Vhd.URI
l["create_option"] = disk.CreateOption
l["caching"] = string(disk.Caching)
if disk.DiskSizeGB != nil {
l["disk_size_gb"] = *disk.DiskSizeGB
}
Expand Down Expand Up @@ -1197,6 +1204,10 @@ func expandAzureRmVirtualMachineDataDisk(d *schema.ResourceData) ([]compute.Data
CreateOption: compute.DiskCreateOptionTypes(createOption),
}

if v := config["caching"].(string); v != "" {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,7 @@ resource "azurerm_virtual_machine" "test" {
vhd_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}/mydatadisk1.vhd"
disk_size_gb = "1023"
create_option = "Empty"
caching = "ReadWrite"
lun = 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ For more information on the different example configurations, please check out t
* `vhd_uri` - (Required) Specifies the uri of the location in storage where the vhd for the virtual machine should be placed.
* `create_option` - (Required) Specifies how the data disk should be created.
* `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.

`os_profile` supports the following:
Expand Down

0 comments on commit 6b6a1c0

Please sign in to comment.