diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index 872200d932da3..1e8079fc35ffd 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -303,7 +303,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { }, "dns_settings": { - Type: schema.TypeSet, + Type: schema.TypeList, Optional: true, MaxItems: 1, Elem: &schema.Resource{ @@ -1050,16 +1050,16 @@ func flattenAzureRmVirtualMachineScaleSetNetworkProfile(profile *compute.Virtual } if netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.DNSSettings != nil { - dnsSettings := make(map[string]interface{}) - dnsServers := make([]interface{}, 0) + dnsSetting := make(map[string]interface{}) + dnsServers := make([]string, 0, len(*netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.DNSSettings.DNSServers)) if netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.DNSSettings.DNSServers != nil { for _, dnsServer := range *netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.DNSSettings.DNSServers { dnsServers = append(dnsServers, dnsServer) } - dnsSettings["dns_servers"] = dnsServers + dnsSetting["dns_servers"] = dnsServers } - s["dns_settings"] = dnsSettings + s["dns_settings"] = []interface{}{dnsSetting} } if netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.IPConfigurations != nil { @@ -1418,7 +1418,7 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) * acceleratedNetworking := config["accelerated_networking"].(bool) ipForwarding := config["ip_forwarding"].(bool) - dnsSettingsConfigs := config["dns_settings"].(*schema.Set).List() + dnsSettingsConfigs := config["dns_settings"].([]interface{}) dnsSettings := compute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{} for _, dnsSettingsConfig := range dnsSettingsConfigs { dns_settings := dnsSettingsConfig.(map[string]interface{}) diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index 34ac72c71cbb2..fa4fef71e4160 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -27,7 +27,6 @@ func TestAccAzureRMVirtualMachineScaleSet_basic(t *testing.T) { testCheckAzureRMVirtualMachineScaleSetExists(resourceName), // testing default scaleset values testCheckAzureRMVirtualMachineScaleSetSinglePlacementGroup(resourceName, true), - resource.TestCheckResourceAttr(resourceName, "ip_forwarding", "false"), ), }, }, @@ -78,6 +77,9 @@ func TestAccAzureRMVirtualMachineScaleSet_basicAcceleratedNetworking(t *testing. func TestAccAzureRMVirtualMachineScaleSet_basicIPForwarding(t *testing.T) { resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() + networkProfileName := fmt.Sprintf("TestNetworkProfile-%d", ri) + networkProfile := map[string]interface{}{"name": networkProfileName, "primary": true} + networkProfileHash := fmt.Sprintf("%d", resourceArmVirtualMachineScaleSetNetworkConfigurationHash(networkProfile)) config := testAccAzureRMVirtualMachineScaleSet_basicIPForwarding(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -88,7 +90,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicIPForwarding(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMVirtualMachineScaleSetExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "ip_forwarding", "true"), + resource.TestCheckResourceAttr(resourceName, "network_profile."+networkProfileHash+".ip_forwarding", "true"), ), }, }, @@ -98,6 +100,9 @@ func TestAccAzureRMVirtualMachineScaleSet_basicIPForwarding(t *testing.T) { func TestAccAzureRMVirtualMachineScaleSet_basicDNSSettings(t *testing.T) { resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() + networkProfileName := fmt.Sprintf("TestNetworkProfile-%d", ri) + networkProfile := map[string]interface{}{"name": networkProfileName, "primary": true} + networkProfileHash := fmt.Sprintf("%d", resourceArmVirtualMachineScaleSetNetworkConfigurationHash(networkProfile)) config := testAccAzureRMVirtualMachineScaleSet_basicDNSSettings(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -108,8 +113,8 @@ func TestAccAzureRMVirtualMachineScaleSet_basicDNSSettings(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMVirtualMachineScaleSetExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "dns_settings.0.dns_servers.0", "8.8.8.8"), - resource.TestCheckResourceAttr(resourceName, "dns_settings.0.dns_servers.1", "8.8.4.4"), + resource.TestCheckResourceAttr(resourceName, "network_profile."+networkProfileHash+".dns_settings.0.dns_servers.0", "8.8.8.8"), + resource.TestCheckResourceAttr(resourceName, "network_profile."+networkProfileHash+".dns_settings.0.dns_servers.1", "8.8.4.4"), ), }, },