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

provider/azurerm: add caching support for virtual_machine data_disks #11142

Merged
merged 1 commit into from
Jan 12, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
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