From 789720f6224284e50c821bdbdaa797bb0af214ea Mon Sep 17 00:00:00 2001 From: "sylvain.boily" Date: Mon, 7 May 2018 10:44:04 -0400 Subject: [PATCH] Adding support for dns_servers and ip_forwarding --- CHANGELOG.md | 4 +- .../resource_arm_virtual_machine_scale_set.go | 61 +- ...urce_arm_virtual_machine_scale_set_test.go | 957 ++++++++++-------- .../r/virtual_machine_scale_set.html.markdown | 11 +- 4 files changed, 626 insertions(+), 407 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 805b5cb3a636..08eb41326ce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -174,7 +174,7 @@ IMPROVEMENTS: * `azurerm_app_service` - allow changing `client_affinity_enabled` without requiring a resource recreation ([#993](https://github.com/terraform-providers/terraform-provider-azurerm/issues/993)) * `azurerm_app_service` - support for configuring `LocalSCM` source control ([#826](https://github.com/terraform-providers/terraform-provider-azurerm/issues/826)) * `azurerm_app_service` - returning a clearer error message when the name (which needs to be globally unique) is in use ([#1037](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1037)) -* `azurerm_cosmosdb_account` - increasing the maximum value for `max_interval_in_seconds` from 100s to 86400s (1 day) [[#1000](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1000)] +* `azurerm_cosmosdb_account` - increasing the maximum value for `max_interval_in_seconds` from 100s to 86400s (1 day) [[#1000](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1000)] * `azurerm_function_app` - returning a clearer error message when the name (which needs to be globally unique) is in use ([#1037](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1037)) * `azurerm_network_interface` - support for attaching to Application Gateways ([#1027](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1027)) * `azurerm_traffic_manager_endpoint` - adding support for `geo_mappings` ([#986](https://github.com/terraform-providers/terraform-provider-azurerm/issues/986)) @@ -352,4 +352,4 @@ IMPROVEMENTS: * core - Upgrading `Azure/azure-sdk-for-go` to v11.2.2-beta ([#594](https://github.com/terraform-providers/terraform-provider-azurerm/issues/594)) * core - upgrading `Azure/go-autorest` to v9.5.2 ([#617](https://github.com/terraform-providers/terraform-provider-azurerm/issues/617)) * core - skipping Resource Provider Registration in AutoRest when opted-out ([#630](https://github.com/terraform-providers/terraform-provider-azurerm/issues/630)) -* `azurerm_app_service` - exposing the Default Hostname as a Computed field +* `azurerm_app_service` - exposing the Default Hostname as a Computed field diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index 1f5b8259536d..d095b7357423 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -303,11 +303,32 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { Optional: true, }, + "ip_forwarding": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "network_security_group_id": { Type: schema.TypeString, Optional: true, }, + "dns_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "dns_servers": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + "ip_configuration": { Type: schema.TypeList, Required: true, @@ -776,7 +797,6 @@ func resourceArmVirtualMachineScaleSetRead(d *schema.ResourceData, meta interfac if upgradePolicy := properties.UpgradePolicy; upgradePolicy != nil { d.Set("upgrade_policy_mode", upgradePolicy.Mode) } - d.Set("overprovision", properties.Overprovision) d.Set("single_placement_group", properties.SinglePlacementGroup) @@ -1036,10 +1056,27 @@ func flattenAzureRmVirtualMachineScaleSetNetworkProfile(profile *compute.Virtual s["accelerated_networking"] = *v } + if v := netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.EnableIPForwarding; v != nil { + s["ip_forwarding"] = *v + } + if v := netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.NetworkSecurityGroup; v != nil { s["network_security_group_id"] = *v.ID } + if netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.DNSSettings != nil { + 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) + } + dnsSetting["dns_servers"] = dnsServers + } + + s["dns_settings"] = []interface{}{dnsSetting} + } + if netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.IPConfigurations != nil { ipConfigs := make([]map[string]interface{}, 0, len(*netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.IPConfigurations)) for _, ipConfig := range *netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.IPConfigurations { @@ -1394,7 +1431,25 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) * name := config["name"].(string) primary := config["primary"].(bool) acceleratedNetworking := config["accelerated_networking"].(bool) - + ipForwarding := config["ip_forwarding"].(bool) + + dnsSettingsConfigs := config["dns_settings"].([]interface{}) + dnsSettings := compute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{} + for _, dnsSettingsConfig := range dnsSettingsConfigs { + dns_settings := dnsSettingsConfig.(map[string]interface{}) + + if v := dns_settings["dns_servers"]; v != nil { + dns_servers := dns_settings["dns_servers"].([]interface{}) + if len(dns_servers) > 0 { + var dnsServers []string + for _, v := range dns_servers { + str := v.(string) + dnsServers = append(dnsServers, str) + } + dnsSettings.DNSServers = &dnsServers + } + } + } ipConfigurationConfigs := config["ip_configuration"].([]interface{}) ipConfigurations := make([]compute.VirtualMachineScaleSetIPConfiguration, 0, len(ipConfigurationConfigs)) for _, ipConfigConfig := range ipConfigurationConfigs { @@ -1486,6 +1541,8 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) * Primary: &primary, IPConfigurations: &ipConfigurations, EnableAcceleratedNetworking: &acceleratedNetworking, + EnableIPForwarding: &ipForwarding, + DNSSettings: &dnsSettings, }, } diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index 0a3359ed555d..0573af551941 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -13,6 +13,7 @@ import ( ) func TestAccAzureRMVirtualMachineScaleSet_basic(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_basic(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -23,10 +24,9 @@ func TestAccAzureRMVirtualMachineScaleSet_basic(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), - - // single placement group should default to true - testCheckAzureRMVirtualMachineScaleSetSinglePlacementGroup("azurerm_virtual_machine_scale_set.test", true), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + // testing default scaleset values + testCheckAzureRMVirtualMachineScaleSetSinglePlacementGroup(resourceName, true), ), }, }, @@ -34,7 +34,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basic(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_basicPublicIP(t *testing.T) { - resource_name := "azurerm_virtual_machine_scale_set.test" + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_basicPublicIP(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -45,9 +45,9 @@ func TestAccAzureRMVirtualMachineScaleSet_basicPublicIP(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists(resource_name), - testCheckAzureRMVirtualMachineScaleSetIsPrimary(resource_name, true), - testCheckAzureRMVirtualMachineScaleSetPublicIPName(resource_name, "TestPublicIPConfiguration"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetIsPrimary(resourceName, true), + testCheckAzureRMVirtualMachineScaleSetPublicIPName(resourceName, "TestPublicIPConfiguration"), ), }, }, @@ -55,7 +55,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicPublicIP(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_basicAcceleratedNetworking(t *testing.T) { - resource_name := "azurerm_virtual_machine_scale_set.test" + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_basicAcceleratedNetworking(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -66,8 +66,55 @@ func TestAccAzureRMVirtualMachineScaleSet_basicAcceleratedNetworking(t *testing. { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists(resource_name), - testCheckAzureRMVirtualMachineScaleSetAcceleratedNetworking(resource_name, true), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetAcceleratedNetworking(resourceName, true), + ), + }, + }, + }) +} + +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) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "network_profile."+networkProfileHash+".ip_forwarding", "true"), + ), + }, + }, + }) +} + +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) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + 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"), ), }, }, @@ -75,7 +122,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicAcceleratedNetworking(t *testing. } func TestAccAzureRMVirtualMachineScaleSet_bootDiagnostic(t *testing.T) { - resource_name := "azurerm_virtual_machine_scale_set.test" + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_bootDiagnostic(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -86,8 +133,8 @@ func TestAccAzureRMVirtualMachineScaleSet_bootDiagnostic(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists(resource_name), - resource.TestCheckResourceAttr(resource_name, "boot_diagnostics.0.enabled", "true"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "boot_diagnostics.0.enabled", "true"), ), }, }, @@ -95,7 +142,7 @@ func TestAccAzureRMVirtualMachineScaleSet_bootDiagnostic(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_networkSecurityGroup(t *testing.T) { - resource_name := "azurerm_virtual_machine_scale_set.test" + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_networkSecurityGroup(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -106,7 +153,7 @@ func TestAccAzureRMVirtualMachineScaleSet_networkSecurityGroup(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists(resource_name), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), ), }, }, @@ -114,6 +161,7 @@ func TestAccAzureRMVirtualMachineScaleSet_networkSecurityGroup(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_basicWindows(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_basicWindows(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -124,10 +172,10 @@ func TestAccAzureRMVirtualMachineScaleSet_basicWindows(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), // single placement group should default to true - testCheckAzureRMVirtualMachineScaleSetSinglePlacementGroup("azurerm_virtual_machine_scale_set.test", true), + testCheckAzureRMVirtualMachineScaleSetSinglePlacementGroup(resourceName, true), ), }, }, @@ -135,6 +183,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicWindows(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_singlePlacementGroupFalse(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_singlePlacementGroupFalse(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -145,8 +194,8 @@ func TestAccAzureRMVirtualMachineScaleSet_singlePlacementGroupFalse(t *testing.T { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), - testCheckAzureRMVirtualMachineScaleSetSinglePlacementGroup("azurerm_virtual_machine_scale_set.test", false), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetSinglePlacementGroup(resourceName, false), ), }, }, @@ -210,6 +259,7 @@ func TestAccAzureRMVirtualMachineScaleSet_customDataUpdated(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -220,7 +270,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), ), }, }, @@ -228,6 +278,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(ri, testLocation(), "Standard_D1_v2") resource.Test(t, resource.TestCase{ @@ -238,7 +289,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), ), }, }, @@ -246,6 +297,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(t *testing.T) } func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk_resize(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() preConfig := testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(ri, testLocation(), "Standard_D1_v2") postConfig := testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(ri, testLocation(), "Standard_D2_v2") @@ -257,13 +309,13 @@ func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk_resize(t *tes { Config: preConfig, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), ), }, { Config: postConfig, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), ), }, }, @@ -271,6 +323,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk_resize(t *tes } func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -281,7 +334,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(t *testin { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), ), }, }, @@ -289,6 +342,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(t *testin } func TestAccAzureRMVirtualMachineScaleSet_basicLinux_disappears(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_basic(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -299,8 +353,8 @@ func TestAccAzureRMVirtualMachineScaleSet_basicLinux_disappears(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), - testCheckAzureRMVirtualMachineScaleSetDisappears("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetDisappears(resourceName), ), ExpectNonEmptyPlan: true, }, @@ -309,6 +363,7 @@ func TestAccAzureRMVirtualMachineScaleSet_basicLinux_disappears(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_planManagedDisk(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_planManagedDisk(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -319,7 +374,7 @@ func TestAccAzureRMVirtualMachineScaleSet_planManagedDisk(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), ), }, }, @@ -327,6 +382,7 @@ func TestAccAzureRMVirtualMachineScaleSet_planManagedDisk(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_customImage(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() resourceGroup := fmt.Sprintf("acctestRG-%d", ri) userName := fmt.Sprintf("testadmin%d", ri) @@ -353,7 +409,7 @@ func TestAccAzureRMVirtualMachineScaleSet_customImage(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), testCheckAzureRMImageExists("azurerm_image.test", true), ), }, @@ -362,6 +418,7 @@ func TestAccAzureRMVirtualMachineScaleSet_customImage(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_applicationGateway(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSetApplicationGatewayTemplate(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -372,8 +429,8 @@ func TestAccAzureRMVirtualMachineScaleSet_applicationGateway(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), - testCheckAzureRMVirtualMachineScaleSetHasApplicationGateway("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetHasApplicationGateway(resourceName), ), }, }, @@ -381,6 +438,7 @@ func TestAccAzureRMVirtualMachineScaleSet_applicationGateway(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_loadBalancer(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSetLoadBalancerTemplate(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -391,8 +449,8 @@ func TestAccAzureRMVirtualMachineScaleSet_loadBalancer(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), - testCheckAzureRMVirtualMachineScaleSetHasLoadbalancer("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetHasLoadbalancer(resourceName), ), }, }, @@ -400,6 +458,7 @@ func TestAccAzureRMVirtualMachineScaleSet_loadBalancer(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_loadBalancerManagedDataDisks(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSetLoadBalancerTemplateManagedDataDisks(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -410,8 +469,8 @@ func TestAccAzureRMVirtualMachineScaleSet_loadBalancerManagedDataDisks(t *testin { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), - testCheckAzureRMVirtualMachineScaleSetHasDataDisks("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetHasDataDisks(resourceName), ), }, }, @@ -419,6 +478,7 @@ func TestAccAzureRMVirtualMachineScaleSet_loadBalancerManagedDataDisks(t *testin } func TestAccAzureRMVirtualMachineScaleSet_overprovision(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSetOverProvisionTemplate(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -429,8 +489,8 @@ func TestAccAzureRMVirtualMachineScaleSet_overprovision(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), - testCheckAzureRMVirtualMachineScaleSetOverprovision("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetOverprovision(resourceName), ), }, }, @@ -475,6 +535,7 @@ func TestAccAzureRMVirtualMachineScaleSet_MSI(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_extension(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSetExtensionTemplate(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -485,8 +546,8 @@ func TestAccAzureRMVirtualMachineScaleSet_extension(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), - testCheckAzureRMVirtualMachineScaleSetExtension("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetExtension(resourceName), ), }, }, @@ -523,6 +584,7 @@ func TestAccAzureRMVirtualMachineScaleSet_extensionUpdate(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_multipleExtensions(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSetMultipleExtensionsTemplate(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -533,8 +595,8 @@ func TestAccAzureRMVirtualMachineScaleSet_multipleExtensions(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), - testCheckAzureRMVirtualMachineScaleSetExtension("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetExtension(resourceName), ), }, }, @@ -558,6 +620,7 @@ func TestAccAzureRMVirtualMachineScaleSet_osDiskTypeConflict(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_NonStandardCasing(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSetNonStandardCasing(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -568,7 +631,7 @@ func TestAccAzureRMVirtualMachineScaleSet_NonStandardCasing(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), ), }, { @@ -581,6 +644,7 @@ func TestAccAzureRMVirtualMachineScaleSet_NonStandardCasing(t *testing.T) { } func TestAccAzureRMVirtualMachineScaleSet_multipleNetworkProfiles(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() config := testAccAzureRMVirtualMachineScaleSet_multipleNetworkProfiles(ri, testLocation()) resource.Test(t, resource.TestCase{ @@ -591,7 +655,7 @@ func TestAccAzureRMVirtualMachineScaleSet_multipleNetworkProfiles(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), ), }, }, @@ -921,38 +985,26 @@ func testCheckAzureRMVirtualMachineScaleSetHasDataDisks(name string) resource.Te func testAccAzureRMVirtualMachineScaleSet_basic(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } -} - resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -971,7 +1023,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -981,15 +1033,15 @@ resource "azurerm_virtual_machine_scale_set" "test" { tier = "Standard" capacity = 2 } - + os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -1011,44 +1063,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_basicPublicIP(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } -} - resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -1067,7 +1107,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -1079,13 +1119,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -1093,7 +1133,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true public_ip_address_configuration { name = "TestPublicIPConfiguration" - domain_name_label = "test-domain-label-%d" + domain_name_label = "test-domain-label-%[1]d" idle_timeout = 4 } } @@ -1113,44 +1153,117 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_basicAcceleratedNetworking(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%d" +resource "azurerm_storage_account" "test" { + name = "accsa%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_tier = "Standard" + account_replication_type = "LRS" + + tags { + environment = "staging" + } +} + +resource "azurerm_storage_container" "test" { + name = "vhds" + resource_group_name = "${azurerm_resource_group.test.name}" + storage_account_name = "${azurerm_storage_account.test.name}" + container_access_type = "private" +} + +resource "azurerm_virtual_machine_scale_set" "test" { + name = "acctvmss-%[1]d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + upgrade_policy_mode = "Manual" + + sku { + name = "Standard_D4_v2" + tier = "Standard" + capacity = 2 + } + + os_profile { + computer_name_prefix = "testvm-%[1]d" + admin_username = "myadmin" + admin_password = "Passwword1234" + } + + network_profile { + name = "TestNetworkProfile-%[1]d" + primary = true + accelerated_networking = true + ip_configuration { + name = "TestIPConfiguration" + subnet_id = "${azurerm_subnet.test.id}" + } + } + + storage_profile_os_disk { + name = "osDiskProfile" + caching = "ReadWrite" + create_option = "FromImage" + vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"] + } + + storage_profile_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "16.04-LTS" + version = "latest" + } +} +`, rInt, location) +} + +func testAccAzureRMVirtualMachineScaleSet_basicIPForwarding(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctvn-%[1]d" + address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" +} - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } +resource "azurerm_subnet" "test" { + name = "acctsub-%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.2.0/24" } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -1169,7 +1282,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -1181,15 +1294,15 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true - accelerated_networking = true + ip_forwarding = true ip_configuration { name = "TestIPConfiguration" subnet_id = "${azurerm_subnet.test.id}" @@ -1210,44 +1323,119 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } -func testAccAzureRMVirtualMachineScaleSet_bootDiagnostic(rInt int, location string) string { +func testAccAzureRMVirtualMachineScaleSet_basicDNSSettings(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%d" +resource "azurerm_storage_account" "test" { + name = "accsa%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_tier = "Standard" + account_replication_type = "LRS" + + tags { + environment = "staging" + } +} + +resource "azurerm_storage_container" "test" { + name = "vhds" + resource_group_name = "${azurerm_resource_group.test.name}" + storage_account_name = "${azurerm_storage_account.test.name}" + container_access_type = "private" +} + +resource "azurerm_virtual_machine_scale_set" "test" { + name = "acctvmss-%[1]d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + upgrade_policy_mode = "Manual" + + sku { + name = "Standard_D4_v2" + tier = "Standard" + capacity = 2 + } + + os_profile { + computer_name_prefix = "testvm-%[1]d" + admin_username = "myadmin" + admin_password = "Passwword1234" + } + + network_profile { + name = "TestNetworkProfile-%[1]d" + primary = true + dns_settings { + dns_servers = ["8.8.8.8", "8.8.4.4"] + } + ip_configuration { + name = "TestIPConfiguration" + subnet_id = "${azurerm_subnet.test.id}" + } + } + + storage_profile_os_disk { + name = "osDiskProfile" + caching = "ReadWrite" + create_option = "FromImage" + vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"] + } + + storage_profile_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "16.04-LTS" + version = "latest" + } +} +`, rInt, location) +} + +func testAccAzureRMVirtualMachineScaleSet_bootDiagnostic(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctvn-%[1]d" + address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" +} - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } +resource "azurerm_subnet" "test" { + name = "acctsub-%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.2.0/24" } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -1266,7 +1454,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -1278,7 +1466,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } @@ -1288,7 +1476,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -1310,44 +1498,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_networkSecurityGroup(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } -} - resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -1366,13 +1542,13 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_network_security_group" "test" { - name = "acceptanceTestSecurityGroup-%d" + name = "acceptanceTestSecurityGroup-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -1384,13 +1560,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true network_security_group_id = "${azurerm_network_security_group.test.id}" ip_configuration { @@ -1399,7 +1575,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true public_ip_address_configuration { name = "TestPublicIPConfiguration" - domain_name_label = "test-domain-label-%d" + domain_name_label = "test-domain-label-%[1]d" idle_timeout = 4 } } @@ -1419,44 +1595,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_basicWindows(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } -} - resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -1475,7 +1639,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -1502,7 +1666,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -1524,14 +1688,14 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_singlePlacementGroupFalse(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%[1]d" - location = "%s" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { @@ -1548,18 +1712,6 @@ resource "azurerm_subnet" "test" { address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%[1]d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } -} - resource "azurerm_storage_account" "test" { name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" @@ -1627,42 +1779,48 @@ resource "azurerm_virtual_machine_scale_set" "test" { func testAccAzureRMVirtualMachineScaleSet_linux(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } + resource "azurerm_virtual_network" "test" { - name = "acctestvn-%d" + name = "acctestvn-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" address_space = ["10.0.0.0/8"] } + resource "azurerm_subnet" "test" { - name = "acctestsn-%d" + name = "acctestsn-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.1.0/24" } + resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" account_replication_type = "LRS" } + resource "azurerm_storage_container" "test" { - name = "acctestsc-%d" + name = "acctestsc-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" storage_account_name = "${azurerm_storage_account.test.name}" container_access_type = "private" } + resource "azurerm_public_ip" "test" { - name = "acctestpip-%d" + name = "acctestpip-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" public_ip_address_allocation = "static" } + resource "azurerm_lb" "test" { - name = "acctestlb-%d" + name = "acctestlb-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" frontend_ip_configuration { @@ -1670,27 +1828,32 @@ resource "azurerm_lb" "test" { public_ip_address_id = "${azurerm_public_ip.test.id}" } } + resource "azurerm_lb_backend_address_pool" "test" { - name = "acctestbap-%d" + name = "acctestbap-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" loadbalancer_id = "${azurerm_lb.test.id}" } + resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctestvmss-%d" + name = "acctestvmss-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" upgrade_policy_mode = "Automatic" + sku { name = "Standard_A0" tier = "Standard" capacity = "1" } + os_profile { computer_name_prefix = "prefix" admin_username = "ubuntu" admin_password = "password" custom_data = "custom data!" } + os_profile_linux_config { disable_password_authentication = true ssh_keys { @@ -1698,6 +1861,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCsTcryUl51Q2VSEHqDRNmceUFo55ZtcIwxl2QITbN1RREti5ml/VTytC0yeBOvnZA4x4CFpdw/lCDPk0yrH9Ei5vVkXmOrExdTlT3qI7YaAzj1tUVlBd4S6LX1F7y6VLActvdHuDDuXZXzCDd/97420jrDfWZqJMlUK/EmCE5ParCeHIRIvmBxcEnGfFIsw8xQZl0HphxWOtJil8qsUWSdMyCiJYYQpMoMliO99X40AUc4/AlsyPyT5ddbKk08YrZ+rKDVHF7o29rh4vi5MmHkVgVQHKiKybWlHq+b71gIAUQk9wrJxD+dqt4igrmDSpIjfjwnd+l5UIn5fJSO5DYV4YT/4hwK7OKmuo7OFHD0WyY5YnkYEMtFgzemnRBdE8ulcT60DQpVgRMXFWHvhyCWy0L6sgj1QWDZlLpvsIvNfHsyhKFMG1frLnMt/nP0+YCcfg+v1JYeCKjeoJxB8DWcRBsjzItY0CGmzP8UYZiYKl/2u+2TgFS5r7NWH11bxoUzjKdaa1NLw+ieA8GlBFfCbfWe6YVB9ggUte4VtYFMZGxOjS2bAiYtfgTKFJv+XqORAwExG6+G2eDxIDyo80/OA9IG7Xv/jwQr7D6KDjDuULFcN/iTxuttoKrHeYz1hf5ZQlBdllwJHYx6fK2g8kha6r2JIQKocvsAXiiONqSfw== hello@world.com" } } + network_profile { name = "TestNetworkProfile" primary = true @@ -1707,6 +1871,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"] } } + storage_profile_os_disk { name = "osDiskProfile" caching = "ReadWrite" @@ -1714,6 +1879,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { os_type = "linux" vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"] } + storage_profile_image_reference { publisher = "Canonical" offer = "UbuntuServer" @@ -1721,48 +1887,54 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_linuxUpdated(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } + resource "azurerm_virtual_network" "test" { - name = "acctestvn-%d" + name = "acctestvn-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" address_space = ["10.0.0.0/8"] } + resource "azurerm_subnet" "test" { - name = "acctestsn-%d" + name = "acctestsn-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.1.0/24" } + resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" account_replication_type = "LRS" } + resource "azurerm_storage_container" "test" { - name = "acctestsc-%d" + name = "acctestsc-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" storage_account_name = "${azurerm_storage_account.test.name}" container_access_type = "private" } + resource "azurerm_public_ip" "test" { - name = "acctestpip-%d" + name = "acctestpip-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" public_ip_address_allocation = "static" } + resource "azurerm_lb" "test" { - name = "acctestlb-%d" + name = "acctestlb-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" frontend_ip_configuration { @@ -1770,27 +1942,32 @@ resource "azurerm_lb" "test" { public_ip_address_id = "${azurerm_public_ip.test.id}" } } + resource "azurerm_lb_backend_address_pool" "test" { - name = "acctestbap-%d" + name = "acctestbap-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" loadbalancer_id = "${azurerm_lb.test.id}" } + resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctestvmss-%d" + name = "acctestvmss-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" upgrade_policy_mode = "Automatic" + sku { name = "Standard_A0" tier = "Standard" capacity = "1" } + os_profile { computer_name_prefix = "prefix" admin_username = "ubuntu" admin_password = "password" custom_data = "custom data!" } + os_profile_linux_config { disable_password_authentication = true ssh_keys { @@ -1798,6 +1975,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCsTcryUl51Q2VSEHqDRNmceUFo55ZtcIwxl2QITbN1RREti5ml/VTytC0yeBOvnZA4x4CFpdw/lCDPk0yrH9Ei5vVkXmOrExdTlT3qI7YaAzj1tUVlBd4S6LX1F7y6VLActvdHuDDuXZXzCDd/97420jrDfWZqJMlUK/EmCE5ParCeHIRIvmBxcEnGfFIsw8xQZl0HphxWOtJil8qsUWSdMyCiJYYQpMoMliO99X40AUc4/AlsyPyT5ddbKk08YrZ+rKDVHF7o29rh4vi5MmHkVgVQHKiKybWlHq+b71gIAUQk9wrJxD+dqt4igrmDSpIjfjwnd+l5UIn5fJSO5DYV4YT/4hwK7OKmuo7OFHD0WyY5YnkYEMtFgzemnRBdE8ulcT60DQpVgRMXFWHvhyCWy0L6sgj1QWDZlLpvsIvNfHsyhKFMG1frLnMt/nP0+YCcfg+v1JYeCKjeoJxB8DWcRBsjzItY0CGmzP8UYZiYKl/2u+2TgFS5r7NWH11bxoUzjKdaa1NLw+ieA8GlBFfCbfWe6YVB9ggUte4VtYFMZGxOjS2bAiYtfgTKFJv+XqORAwExG6+G2eDxIDyo80/OA9IG7Xv/jwQr7D6KDjDuULFcN/iTxuttoKrHeYz1hf5ZQlBdllwJHYx6fK2g8kha6r2JIQKocvsAXiiONqSfw== hello@world.com" } } + network_profile { name = "TestNetworkProfile" primary = true @@ -1807,6 +1985,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"] } } + storage_profile_os_disk { name = "osDiskProfile" caching = "ReadWrite" @@ -1814,58 +1993,66 @@ resource "azurerm_virtual_machine_scale_set" "test" { os_type = "linux" vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"] } + storage_profile_image_reference { publisher = "Canonical" offer = "UbuntuServer" sku = "16.04-LTS" version = "latest" } + tags { ThisIs = "a test" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_linuxCustomDataUpdated(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } + resource "azurerm_virtual_network" "test" { - name = "acctestvn-%d" + name = "acctestvn-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" address_space = ["10.0.0.0/8"] } + resource "azurerm_subnet" "test" { - name = "acctestsn-%d" + name = "acctestsn-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.1.0/24" } + resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" account_replication_type = "LRS" } + resource "azurerm_storage_container" "test" { - name = "acctestsc-%d" + name = "acctestsc-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" storage_account_name = "${azurerm_storage_account.test.name}" container_access_type = "private" } + resource "azurerm_public_ip" "test" { - name = "acctestpip-%d" + name = "acctestpip-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" public_ip_address_allocation = "static" } + resource "azurerm_lb" "test" { - name = "acctestlb-%d" + name = "acctestlb-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" frontend_ip_configuration { @@ -1873,27 +2060,32 @@ resource "azurerm_lb" "test" { public_ip_address_id = "${azurerm_public_ip.test.id}" } } + resource "azurerm_lb_backend_address_pool" "test" { - name = "acctestbap-%d" + name = "acctestbap-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" loadbalancer_id = "${azurerm_lb.test.id}" } + resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctestvmss-%d" + name = "acctestvmss-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" upgrade_policy_mode = "Automatic" + sku { name = "Standard_A0" tier = "Standard" capacity = "1" } + os_profile { computer_name_prefix = "prefix" admin_username = "ubuntu" admin_password = "password" custom_data = "updated custom data!" } + os_profile_linux_config { disable_password_authentication = true ssh_keys { @@ -1901,6 +2093,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCsTcryUl51Q2VSEHqDRNmceUFo55ZtcIwxl2QITbN1RREti5ml/VTytC0yeBOvnZA4x4CFpdw/lCDPk0yrH9Ei5vVkXmOrExdTlT3qI7YaAzj1tUVlBd4S6LX1F7y6VLActvdHuDDuXZXzCDd/97420jrDfWZqJMlUK/EmCE5ParCeHIRIvmBxcEnGfFIsw8xQZl0HphxWOtJil8qsUWSdMyCiJYYQpMoMliO99X40AUc4/AlsyPyT5ddbKk08YrZ+rKDVHF7o29rh4vi5MmHkVgVQHKiKybWlHq+b71gIAUQk9wrJxD+dqt4igrmDSpIjfjwnd+l5UIn5fJSO5DYV4YT/4hwK7OKmuo7OFHD0WyY5YnkYEMtFgzemnRBdE8ulcT60DQpVgRMXFWHvhyCWy0L6sgj1QWDZlLpvsIvNfHsyhKFMG1frLnMt/nP0+YCcfg+v1JYeCKjeoJxB8DWcRBsjzItY0CGmzP8UYZiYKl/2u+2TgFS5r7NWH11bxoUzjKdaa1NLw+ieA8GlBFfCbfWe6YVB9ggUte4VtYFMZGxOjS2bAiYtfgTKFJv+XqORAwExG6+G2eDxIDyo80/OA9IG7Xv/jwQr7D6KDjDuULFcN/iTxuttoKrHeYz1hf5ZQlBdllwJHYx6fK2g8kha6r2JIQKocvsAXiiONqSfw== hello@world.com" } } + network_profile { name = "TestNetworkProfile" primary = true @@ -1910,6 +2103,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"] } } + storage_profile_os_disk { name = "osDiskProfile" caching = "ReadWrite" @@ -1917,6 +2111,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { os_type = "linux" vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"] } + storage_profile_image_reference { publisher = "Canonical" offer = "UbuntuServer" @@ -1924,32 +2119,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -1961,13 +2156,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -1989,32 +2184,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk_withZones(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -2027,13 +2222,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -2054,38 +2249,38 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_basicWindows_managedDisk(rInt int, location string, vmSize string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" sku { - name = "%s" + name = "%[3]s" tier = "Standard" capacity = 2 } @@ -2116,7 +2311,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -2138,32 +2333,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, vmSize, rInt) +`, rInt, location, vmSize) } func testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDiskNoName(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -2175,13 +2370,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -2202,32 +2397,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSetApplicationGatewayTemplate(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -2242,7 +2437,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -2254,7 +2449,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } @@ -2287,21 +2482,21 @@ resource "azurerm_virtual_machine_scale_set" "test" { # application gateway resource "azurerm_subnet" "gwtest" { - name = "gw-subnet-%d" + name = "gw-subnet-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.3.0/24" } resource "azurerm_public_ip" "test" { - name = "acctest-pubip-%d" + name = "acctest-pubip-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" public_ip_address_allocation = "dynamic" } resource "azurerm_application_gateway" "test" { - name = "acctestgw-%d" + name = "acctestgw-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" @@ -2397,32 +2592,32 @@ resource "azurerm_application_gateway" "test" { environment = "tf01" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSetLoadBalancerTemplate(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -2437,7 +2632,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_lb" "test" { - name = "acctestlb-%d" + name = "acctestlb-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" @@ -2467,7 +2662,7 @@ resource "azurerm_lb_nat_pool" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -2479,7 +2674,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } @@ -2511,32 +2706,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSetOverProvisionTemplate(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -2551,7 +2746,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -2564,7 +2759,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } @@ -2594,14 +2789,14 @@ resource "azurerm_virtual_machine_scale_set" "test" { } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSetPriorityTemplate(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestrg-%[1]d" - location = "%s" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { @@ -2684,26 +2879,26 @@ resource "azurerm_virtual_machine_scale_set" "test" { func testAccAzureRMVirtualMachineScaleSetMSITemplate(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -2718,7 +2913,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -2733,17 +2928,17 @@ resource "azurerm_virtual_machine_scale_set" "test" { identity { type = "systemAssigned" } - + extension { name = "MSILinuxExtension" publisher = "Microsoft.ManagedIdentity" type = "ManagedIdentityExtensionForLinux" type_handler_version = "1.0" settings = "{\"port\": 50342}" - } + } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } @@ -2773,32 +2968,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSetExtensionTemplate(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -2813,7 +3008,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -2826,7 +3021,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } @@ -2884,32 +3079,32 @@ SETTINGS SETTINGS } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSetExtensionTemplateUpdated(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -2924,7 +3119,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -2937,7 +3132,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } @@ -2996,32 +3191,32 @@ SETTINGS SETTINGS } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSetMultipleExtensionsTemplate(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -3036,7 +3231,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -3049,7 +3244,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } @@ -3108,44 +3303,32 @@ SETTINGS } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_osDiskTypeConflict(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } -} - resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -3157,13 +3340,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { @@ -3188,32 +3371,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSetLoadBalancerTemplateManagedDataDisks(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestrg-%d" - location = "%s" + name = "acctestrg-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_lb" "test" { - name = "acctestlb-%d" + name = "acctestlb-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" @@ -3231,7 +3414,7 @@ resource "azurerm_lb_backend_address_pool" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -3243,7 +3426,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } @@ -3282,44 +3465,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSetNonStandardCasing(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } -} - resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -3338,7 +3509,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -3350,13 +3521,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { @@ -3379,32 +3550,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_planManagedDisk(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -3416,13 +3587,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -3449,40 +3620,40 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } func testAccAzureRMVirtualMachineScaleSet_customImage(rInt int, location string, userName string, password string, hostName string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_public_ip" "test" { - name = "acctpip-%d" + name = "acctpip-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" public_ip_address_allocation = "Dynamic" - domain_name_label = "%s" + domain_name_label = "%[3]s" } resource "azurerm_network_interface" "testsource" { - name = "acctnicsource-%d" + name = "acctnicsource-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" @@ -3495,7 +3666,7 @@ resource "azurerm_network_interface" "testsource" { } resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -3537,8 +3708,8 @@ resource "azurerm_virtual_machine" "testsource" { os_profile { computer_name = "mdimagetestsource" - admin_username = "%s" - admin_password = "%s" + admin_username = "%[4]s" + admin_password = "%[5]s" } os_profile_linux_config { @@ -3552,7 +3723,7 @@ resource "azurerm_virtual_machine" "testsource" { } resource "azurerm_image" "test" { - name = "accteste-%d" + name = "accteste-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" @@ -3577,7 +3748,7 @@ resource "azurerm_image" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -3593,13 +3764,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "TestNetworkProfile-%d" + name = "TestNetworkProfile-%[1]d" primary = true ip_configuration { name = "TestIPConfiguration" @@ -3613,44 +3784,32 @@ resource "azurerm_virtual_machine_scale_set" "test" { managed_disk_type = "Standard_LRS" } } -`, rInt, location, rInt, rInt, rInt, hostName, rInt, rInt, userName, password, rInt, rInt, rInt, rInt) +`, rInt, location, hostName, userName, password) } func testAccAzureRMVirtualMachineScaleSet_multipleNetworkProfiles(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctvn-%[1]d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctsub-%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } -resource "azurerm_network_interface" "test" { - name = "acctni-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - - ip_configuration { - name = "testconfiguration1" - subnet_id = "${azurerm_subnet.test.id}" - private_ip_address_allocation = "dynamic" - } -} - resource "azurerm_storage_account" "test" { - name = "accsa%d" + name = "accsa%[1]d" resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" account_tier = "Standard" @@ -3669,7 +3828,7 @@ resource "azurerm_storage_container" "test" { } resource "azurerm_virtual_machine_scale_set" "test" { - name = "acctvmss-%d" + name = "acctvmss-%[1]d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" upgrade_policy_mode = "Manual" @@ -3681,13 +3840,13 @@ resource "azurerm_virtual_machine_scale_set" "test" { } os_profile { - computer_name_prefix = "testvm-%d" + computer_name_prefix = "testvm-%[1]d" admin_username = "myadmin" admin_password = "Passwword1234" } network_profile { - name = "primary-%d" + name = "primary-%[1]d" primary = true ip_configuration { name = "primary" @@ -3696,7 +3855,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } network_profile { - name = "secondary-%d" + name = "secondary-%[1]d" primary = false ip_configuration { name = "secondary" @@ -3718,5 +3877,5 @@ resource "azurerm_virtual_machine_scale_set" "test" { version = "latest" } } -`, rInt, location, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt) +`, rInt, location) } diff --git a/website/docs/r/virtual_machine_scale_set.html.markdown b/website/docs/r/virtual_machine_scale_set.html.markdown index 7d3c93151961..25a541c86046 100644 --- a/website/docs/r/virtual_machine_scale_set.html.markdown +++ b/website/docs/r/virtual_machine_scale_set.html.markdown @@ -353,10 +353,14 @@ resource "azurerm_virtual_machine_scale_set" "test" { * `name` - (Required) Specifies the name of the network interface configuration. * `primary` - (Required) Indicates whether network interfaces created from the network interface configuration will be the primary NIC of the VM. -* `ip_configuration` - (Required) An ip_configuration block as documented below +* `ip_configuration` - (Required) An ip_configuration block as documented below. +* `accelerated_networking` - (Optional) Specifies whether to enable accelerated networking or not. Defaults to `false`. +* `dns_settings` - (Optional) An dns_settings block as documented below. * `network_security_group_id` - (Optional) Specifies the identifier for the network security group. -* `accelerated_networking` - (Optional) Specifies whether to enable accelerated networking or not. Defaults to -`false`. + +`dns_settings` supports the following: + +* `dns_servers` - (Required) Specifies an array of dns servers. `ip_configuration` supports the following: @@ -452,7 +456,6 @@ The following attributes are exported: * `id` - The virtual machine scale set ID. - ## Import Virtual Machine Scale Sets can be imported using the `resource id`, e.g.