From e2f1620fcc8ca04a9d5c50c0e706f6b340a778c2 Mon Sep 17 00:00:00 2001 From: Vaijanath Angadihiremath Date: Thu, 8 Feb 2018 19:47:55 +0000 Subject: [PATCH 1/4] Fix reprovisioning of VM when we attach and detach data disk. --- azurerm/resource_arm_virtual_machine.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go index ea65d3740e17..50eb770ea4a9 100644 --- a/azurerm/resource_arm_virtual_machine.go +++ b/azurerm/resource_arm_virtual_machine.go @@ -254,7 +254,6 @@ func resourceArmVirtualMachine() *schema.Resource { "managed_disk_id": { Type: schema.TypeString, Optional: true, - ForceNew: true, Computed: true, DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, @@ -272,7 +271,6 @@ func resourceArmVirtualMachine() *schema.Resource { "create_option": { Type: schema.TypeString, Required: true, - ForceNew: true, DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, From 959cf3075cc38c2a9b9b6b83ca07d3d749b699d5 Mon Sep 17 00:00:00 2001 From: Vaijanath Angadihiremath Date: Fri, 9 Feb 2018 00:02:46 +0000 Subject: [PATCH 2/4] Fixing the test case to reflect the new behavior --- ...ource_arm_virtual_machine_managed_disks_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine_managed_disks_test.go b/azurerm/resource_arm_virtual_machine_managed_disks_test.go index 715b28ebb518..6849eb8d8f2b 100644 --- a/azurerm/resource_arm_virtual_machine_managed_disks_test.go +++ b/azurerm/resource_arm_virtual_machine_managed_disks_test.go @@ -227,7 +227,7 @@ func TestAccAzureRMVirtualMachine_bugAzureRM33(t *testing.T) { }) } -func TestAccAzureRMVirtualMachine_changeStorageDataDiskCreationOption(t *testing.T) { +func TestAccAzureRMVirtualMachine_attachSecondDataDiskWithAttachOption(t *testing.T) { var afterCreate, afterUpdate compute.VirtualMachine resourceName := "azurerm_virtual_machine.test" ri := acctest.RandInt() @@ -619,7 +619,7 @@ resource "azurerm_network_interface" "test" { } resource "azurerm_managed_disk" "test" { - name = "acctmd-%d" + name = "acctmd2-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" storage_account_type = "Standard_LRS" @@ -649,11 +649,19 @@ resource "azurerm_virtual_machine" "test" { managed_disk_type = "Standard_LRS" } + storage_data_disk { + name = "acctmd-%d" + create_option = "Empty" + disk_size_gb = "1" + lun = 0 + managed_disk_type = "Standard_LRS" + } + storage_data_disk { name = "${azurerm_managed_disk.test.name}" create_option = "Attach" disk_size_gb = "1" - lun = 0 + lun = 1 managed_disk_id = "${azurerm_managed_disk.test.id}" } From ac369881beb0fdb3cc8f5263f7ba1790248f9d04 Mon Sep 17 00:00:00 2001 From: Vaijanath Angadihiremath Date: Fri, 9 Feb 2018 00:15:58 +0000 Subject: [PATCH 3/4] Fixing the test failure --- azurerm/resource_arm_virtual_machine_managed_disks_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_virtual_machine_managed_disks_test.go b/azurerm/resource_arm_virtual_machine_managed_disks_test.go index 6849eb8d8f2b..c80ea92e84bb 100644 --- a/azurerm/resource_arm_virtual_machine_managed_disks_test.go +++ b/azurerm/resource_arm_virtual_machine_managed_disks_test.go @@ -680,7 +680,7 @@ resource "azurerm_virtual_machine" "test" { cost-center = "Ops" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt) } func testAccAzureRMVirtualMachine_basicLinuxMachine_managedDisk_empty(rInt int, location string) string { From 23c736f94e723ca1525cdae81d39f5bb4c1c0735 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 14 Feb 2018 15:13:14 -0800 Subject: [PATCH 4/4] Fixing a broken test --- azurerm/resource_arm_virtual_machine_managed_disks_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_virtual_machine_managed_disks_test.go b/azurerm/resource_arm_virtual_machine_managed_disks_test.go index c80ea92e84bb..38b3c325d198 100644 --- a/azurerm/resource_arm_virtual_machine_managed_disks_test.go +++ b/azurerm/resource_arm_virtual_machine_managed_disks_test.go @@ -251,7 +251,8 @@ func TestAccAzureRMVirtualMachine_attachSecondDataDiskWithAttachOption(t *testin Check: resource.ComposeTestCheckFunc( testCheckAzureRMVirtualMachineExists(resourceName, &afterUpdate), testAccCheckVirtualMachineRecreated(t, &afterCreate, &afterUpdate), - resource.TestCheckResourceAttr(resourceName, "storage_data_disk.0.create_option", "Attach"), + resource.TestCheckResourceAttr(resourceName, "storage_data_disk.0.create_option", "Empty"), + resource.TestCheckResourceAttr(resourceName, "storage_data_disk.1.create_option", "Attach"), ), }, },