From 50b859ba9afb4efbdcfbc62da2ca9b86450e542d Mon Sep 17 00:00:00 2001 From: Christian Karlsen Date: Fri, 18 Nov 2016 23:08:49 +0100 Subject: [PATCH 1/2] provider/azurerm: make DiskSizeGB optional for data disks --- builtin/providers/azurerm/resource_arm_virtual_machine.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine.go b/builtin/providers/azurerm/resource_arm_virtual_machine.go index d97ebaf37..2464d7986 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine.go @@ -195,7 +195,7 @@ func resourceArmVirtualMachine() *schema.Resource { "disk_size_gb": { Type: schema.TypeInt, - Required: true, + Optional: true, ValidateFunc: validateDiskSizeGB, }, @@ -840,7 +840,9 @@ func flattenAzureRmVirtualMachineDataDisk(disks *[]compute.DataDisk) interface{} l["name"] = *disk.Name l["vhd_uri"] = *disk.Vhd.URI l["create_option"] = disk.CreateOption - l["disk_size_gb"] = *disk.DiskSizeGB + if disk.DiskSizeGB != nil { + l["disk_size_gb"] = *disk.DiskSizeGB + } l["lun"] = *disk.Lun result[i] = l From 63aa6a1fcda7fc94bd4c6063a4995c68af96418f Mon Sep 17 00:00:00 2001 From: stack72 Date: Mon, 5 Dec 2016 15:05:21 +0000 Subject: [PATCH 2/2] provider/azurerm: removing azurerm_virtual_machine data_disk disk_size_in_gb --- .../azurerm/resource_arm_virtual_machine.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine.go b/builtin/providers/azurerm/resource_arm_virtual_machine.go index 415e4ce57..e8ba6d62e 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine.go @@ -197,9 +197,9 @@ func resourceArmVirtualMachine() *schema.Resource { }, "disk_size_gb": { - Type: schema.TypeInt, - Optional: true, - ValidateFunc: validateDiskSizeGB, + Type: schema.TypeInt, + Optional: true, + Computed: true, }, "lun": { @@ -1172,7 +1172,6 @@ func expandAzureRmVirtualMachineDataDisk(d *schema.ResourceData) ([]compute.Data vhd := config["vhd_uri"].(string) createOption := config["create_option"].(string) lun := int32(config["lun"].(int)) - disk_size := int32(config["disk_size_gb"].(int)) data_disk := compute.DataDisk{ Name: &name, @@ -1180,10 +1179,14 @@ func expandAzureRmVirtualMachineDataDisk(d *schema.ResourceData) ([]compute.Data URI: &vhd, }, Lun: &lun, - DiskSizeGB: &disk_size, CreateOption: compute.DiskCreateOptionTypes(createOption), } + if v := config["disk_size_gb"]; v != nil { + diskSize := int32(config["disk_size_gb"].(int)) + data_disk.DiskSizeGB = &diskSize + } + data_disks = append(data_disks, data_disk) }