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

Bugfix: Update of Windows vm and vmss with non-empty additional_unattend_config.content #377

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
5 changes: 4 additions & 1 deletion azurerm/resource_arm_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,10 @@ func expandAzureRmVirtualMachineOsProfileWindowsConfig(d *schema.ResourceData) (
PassName: compute.PassNames(pass),
ComponentName: compute.ComponentNames(component),
SettingName: compute.SettingNames(settingName),
Content: &content,
}

if content != "" {
addContent.Content = &content
}

additionalConfigContent = append(additionalConfigContent, addContent)
Expand Down
5 changes: 4 additions & 1 deletion azurerm/resource_arm_virtual_machine_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,10 @@ func expandAzureRmVirtualMachineScaleSetOsProfileWindowsConfig(d *schema.Resourc
PassName: compute.PassNames(pass),
ComponentName: compute.ComponentNames(component),
SettingName: compute.SettingNames(settingName),
Content: &content,
}

if content != "" {
addContent.Content = &content
}

additionalConfigContent = append(additionalConfigContent, addContent)
Expand Down
33 changes: 29 additions & 4 deletions azurerm/resource_arm_virtual_machine_scale_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk(t *testing.T) {

func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(ri, testLocation())
config := testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(ri, testLocation(), "Standard_D1_v2")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -137,6 +137,31 @@ func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(t *testing.T)
})
}

func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk_resize(t *testing.T) {
ri := acctest.RandInt()
preConfig := testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(ri, testLocation(), "Standard_D1_v2")
postConfig := testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(ri, testLocation(), "Standard_D2_v2")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
Steps: []resource.TestStep{
{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"),
),
},
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"),
),
},
},
})
}

func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(ri, testLocation())
Expand Down Expand Up @@ -1080,7 +1105,7 @@ resource "azurerm_virtual_machine_scale_set" "test" {
`, rInt, location, rInt, rInt, rInt, rInt, rInt)
}

func testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(rInt int, location string) string {
func testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(rInt int, location string, vmSize string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -1108,7 +1133,7 @@ resource "azurerm_virtual_machine_scale_set" "test" {
upgrade_policy_mode = "Manual"

sku {
name = "Standard_D1_v2"
name = "%s"
tier = "Standard"
capacity = 2
}
Expand Down Expand Up @@ -1161,7 +1186,7 @@ resource "azurerm_virtual_machine_scale_set" "test" {
version = "latest"
}
}
`, rInt, location, rInt, rInt, rInt, rInt)
`, rInt, location, rInt, rInt, rInt, vmSize, rInt)
}

func testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(rInt int, location string) string {
Expand Down
34 changes: 30 additions & 4 deletions azurerm/resource_arm_virtual_machine_unmanaged_disks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestAccAzureRMVirtualMachine_basicWindowsMachine(t *testing.T) {
func TestAccAzureRMVirtualMachine_windowsUnattendedConfig(t *testing.T) {
var vm compute.VirtualMachine
ri := acctest.RandInt()
config := testAccAzureRMVirtualMachine_windowsUnattendedConfig(ri, testLocation())
config := testAccAzureRMVirtualMachine_windowsUnattendedConfig(ri, testLocation(), "Standard_D1_v2")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -196,6 +196,32 @@ func TestAccAzureRMVirtualMachine_windowsUnattendedConfig(t *testing.T) {
})
}

func TestAccAzureRMVirtualMachine_windowsMachineResize(t *testing.T) {
var vm compute.VirtualMachine
ri := acctest.RandInt()
preConfig := testAccAzureRMVirtualMachine_windowsUnattendedConfig(ri, testLocation(), "Standard_D1_v2")
postConfig := testAccAzureRMVirtualMachine_windowsUnattendedConfig(ri, testLocation(), "Standard_D2_v2")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
Steps: []resource.TestStep{
{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
),
},
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists("azurerm_virtual_machine.test", &vm),
),
},
},
})
}

func TestAccAzureRMVirtualMachine_diagnosticsProfile(t *testing.T) {
var vm compute.VirtualMachine
ri := acctest.RandInt()
Expand Down Expand Up @@ -1382,7 +1408,7 @@ resource "azurerm_virtual_machine" "test" {
`, rInt, location, rInt, rInt, rInt, rInt, rInt)
}

func testAccAzureRMVirtualMachine_windowsUnattendedConfig(rInt int, location string) string {
func testAccAzureRMVirtualMachine_windowsUnattendedConfig(rInt int, location string, vmSize string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand Down Expand Up @@ -1438,7 +1464,7 @@ resource "azurerm_virtual_machine" "test" {
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
vm_size = "Standard_D1_v2"
vm_size = "%s"

storage_image_reference {
publisher = "MicrosoftWindowsServer"
Expand Down Expand Up @@ -1471,7 +1497,7 @@ resource "azurerm_virtual_machine" "test" {
}

}
`, rInt, location, rInt, rInt, rInt, rInt, rInt)
`, rInt, location, rInt, rInt, rInt, rInt, rInt, vmSize)
}

func testAccAzureRMVirtualMachine_diagnosticsProfile(rInt int, location string) string {
Expand Down