github.com/IBM-Cloud/terraform@v0.6.4-0.20170726051544-8872b87621df/builtin/providers/azurerm/resource_arm_virtual_machine_scale_set_test.go (about)

     1  package azurerm
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"regexp"
     7  	"testing"
     8  
     9  	"github.com/hashicorp/terraform/helper/acctest"
    10  	"github.com/hashicorp/terraform/helper/resource"
    11  	"github.com/hashicorp/terraform/terraform"
    12  )
    13  
    14  func TestAccAzureRMVirtualMachineScaleSet_basic(t *testing.T) {
    15  	ri := acctest.RandInt()
    16  	config := fmt.Sprintf(testAccAzureRMVirtualMachineScaleSet_basic, ri, ri, ri, ri, ri, ri, ri, ri)
    17  	resource.Test(t, resource.TestCase{
    18  		PreCheck:     func() { testAccPreCheck(t) },
    19  		Providers:    testAccProviders,
    20  		CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
    21  		Steps: []resource.TestStep{
    22  			{
    23  				Config: config,
    24  				Check: resource.ComposeTestCheckFunc(
    25  					testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"),
    26  				),
    27  			},
    28  		},
    29  	})
    30  }
    31  
    32  func TestAccAzureRMVirtualMachineScaleSet_linuxUpdated(t *testing.T) {
    33  	resourceName := "azurerm_virtual_machine_scale_set.test"
    34  	ri := acctest.RandInt()
    35  	config := testAccAzureRMVirtualMachineScaleSet_linux(ri)
    36  	updatedConfig := testAccAzureRMVirtualMachineScaleSet_linuxUpdated(ri)
    37  
    38  	resource.Test(t, resource.TestCase{
    39  		PreCheck:     func() { testAccPreCheck(t) },
    40  		Providers:    testAccProviders,
    41  		CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
    42  		Steps: []resource.TestStep{
    43  			{
    44  				Config: config,
    45  				Check: resource.ComposeTestCheckFunc(
    46  					testCheckAzureRMVirtualMachineScaleSetExists(resourceName),
    47  				),
    48  			},
    49  			{
    50  				Config: updatedConfig,
    51  				Check: resource.ComposeTestCheckFunc(
    52  					testCheckAzureRMVirtualMachineScaleSetExists(resourceName),
    53  				),
    54  			},
    55  		},
    56  	})
    57  }
    58  
    59  func TestAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk(t *testing.T) {
    60  	ri := acctest.RandInt()
    61  	config := fmt.Sprintf(testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk, ri, ri, ri, ri, ri, ri)
    62  	resource.Test(t, resource.TestCase{
    63  		PreCheck:     func() { testAccPreCheck(t) },
    64  		Providers:    testAccProviders,
    65  		CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
    66  		Steps: []resource.TestStep{
    67  			{
    68  				Config: config,
    69  				Check: resource.ComposeTestCheckFunc(
    70  					testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"),
    71  				),
    72  			},
    73  		},
    74  	})
    75  }
    76  
    77  func TestAccAzureRMVirtualMachineScaleSet_basicLinux_disappears(t *testing.T) {
    78  	ri := acctest.RandInt()
    79  	config := fmt.Sprintf(testAccAzureRMVirtualMachineScaleSet_basic, ri, ri, ri, ri, ri, ri, ri, ri)
    80  	resource.Test(t, resource.TestCase{
    81  		PreCheck:     func() { testAccPreCheck(t) },
    82  		Providers:    testAccProviders,
    83  		CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
    84  		Steps: []resource.TestStep{
    85  			{
    86  				Config: config,
    87  				Check: resource.ComposeTestCheckFunc(
    88  					testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"),
    89  					testCheckAzureRMVirtualMachineScaleSetDisappears("azurerm_virtual_machine_scale_set.test"),
    90  				),
    91  				ExpectNonEmptyPlan: true,
    92  			},
    93  		},
    94  	})
    95  }
    96  
    97  func TestAccAzureRMVirtualMachineScaleSet_loadBalancer(t *testing.T) {
    98  	ri := acctest.RandInt()
    99  	config := fmt.Sprintf(testAccAzureRMVirtualMachineScaleSetLoadbalancerTemplate, ri, ri, ri, ri, ri, ri, ri)
   100  	resource.Test(t, resource.TestCase{
   101  		PreCheck:     func() { testAccPreCheck(t) },
   102  		Providers:    testAccProviders,
   103  		CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
   104  		Steps: []resource.TestStep{
   105  			{
   106  				Config: config,
   107  				Check: resource.ComposeTestCheckFunc(
   108  					testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"),
   109  					testCheckAzureRMVirtualMachineScaleSetHasLoadbalancer("azurerm_virtual_machine_scale_set.test"),
   110  				),
   111  			},
   112  		},
   113  	})
   114  }
   115  
   116  func TestAccAzureRMVirtualMachineScaleSet_overprovision(t *testing.T) {
   117  	ri := acctest.RandInt()
   118  	config := fmt.Sprintf(testAccAzureRMVirtualMachineScaleSetOverprovisionTemplate, ri, ri, ri, ri, ri, ri)
   119  	resource.Test(t, resource.TestCase{
   120  		PreCheck:     func() { testAccPreCheck(t) },
   121  		Providers:    testAccProviders,
   122  		CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
   123  		Steps: []resource.TestStep{
   124  			{
   125  				Config: config,
   126  				Check: resource.ComposeTestCheckFunc(
   127  					testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"),
   128  					testCheckAzureRMVirtualMachineScaleSetOverprovision("azurerm_virtual_machine_scale_set.test"),
   129  				),
   130  			},
   131  		},
   132  	})
   133  }
   134  
   135  func TestAccAzureRMVirtualMachineScaleSet_extension(t *testing.T) {
   136  	ri := acctest.RandInt()
   137  	config := fmt.Sprintf(testAccAzureRMVirtualMachineScaleSetExtensionTemplate, ri, ri, ri, ri, ri, ri)
   138  	resource.Test(t, resource.TestCase{
   139  		PreCheck:     func() { testAccPreCheck(t) },
   140  		Providers:    testAccProviders,
   141  		CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
   142  		Steps: []resource.TestStep{
   143  			{
   144  				Config: config,
   145  				Check: resource.ComposeTestCheckFunc(
   146  					testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"),
   147  					testCheckAzureRMVirtualMachineScaleSetExtension("azurerm_virtual_machine_scale_set.test"),
   148  				),
   149  			},
   150  		},
   151  	})
   152  }
   153  
   154  func TestAccAzureRMVirtualMachineScaleSet_multipleExtensions(t *testing.T) {
   155  	ri := acctest.RandInt()
   156  	config := fmt.Sprintf(testAccAzureRMVirtualMachineScaleSetMultipleExtensionsTemplate, ri, ri, ri, ri, ri, ri)
   157  	resource.Test(t, resource.TestCase{
   158  		PreCheck:     func() { testAccPreCheck(t) },
   159  		Providers:    testAccProviders,
   160  		CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
   161  		Steps: []resource.TestStep{
   162  			{
   163  				Config: config,
   164  				Check: resource.ComposeTestCheckFunc(
   165  					testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"),
   166  					testCheckAzureRMVirtualMachineScaleSetExtension("azurerm_virtual_machine_scale_set.test"),
   167  				),
   168  			},
   169  		},
   170  	})
   171  }
   172  
   173  func TestAccAzureRMVirtualMachineScaleSet_osDiskTypeConflict(t *testing.T) {
   174  	ri := acctest.RandInt()
   175  	config := fmt.Sprintf(testAccAzureRMVirtualMachineScaleSet_osDiskTypeConflict, ri, ri, ri, ri, ri, ri, ri)
   176  	resource.Test(t, resource.TestCase{
   177  		PreCheck:     func() { testAccPreCheck(t) },
   178  		Providers:    testAccProviders,
   179  		CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy,
   180  		Steps: []resource.TestStep{
   181  			{
   182  				Config:      config,
   183  				ExpectError: regexp.MustCompile("Conflict between `vhd_containers`"),
   184  				//Use below code instead once GH-13019 has been merged
   185  				//ExpectError: regexp.MustCompile("conflicts with storage_profile_os_disk.0.vhd_containers"),
   186  			},
   187  		},
   188  	})
   189  }
   190  
   191  func testCheckAzureRMVirtualMachineScaleSetExists(name string) resource.TestCheckFunc {
   192  	return func(s *terraform.State) error {
   193  		// Ensure we have enough information in state to look up in API
   194  		rs, ok := s.RootModule().Resources[name]
   195  		if !ok {
   196  			return fmt.Errorf("Not found: %s", name)
   197  		}
   198  
   199  		name := rs.Primary.Attributes["name"]
   200  		resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
   201  		if !hasResourceGroup {
   202  			return fmt.Errorf("Bad: no resource group found in state for virtual machine: scale set %s", name)
   203  		}
   204  
   205  		conn := testAccProvider.Meta().(*ArmClient).vmScaleSetClient
   206  
   207  		resp, err := conn.Get(resourceGroup, name)
   208  		if err != nil {
   209  			return fmt.Errorf("Bad: Get on vmScaleSetClient: %s", err)
   210  		}
   211  
   212  		if resp.StatusCode == http.StatusNotFound {
   213  			return fmt.Errorf("Bad: VirtualMachineScaleSet %q (resource group: %q) does not exist", name, resourceGroup)
   214  		}
   215  
   216  		return nil
   217  	}
   218  }
   219  
   220  func testCheckAzureRMVirtualMachineScaleSetDisappears(name string) resource.TestCheckFunc {
   221  	return func(s *terraform.State) error {
   222  		// Ensure we have enough information in state to look up in API
   223  		rs, ok := s.RootModule().Resources[name]
   224  		if !ok {
   225  			return fmt.Errorf("Not found: %s", name)
   226  		}
   227  
   228  		name := rs.Primary.Attributes["name"]
   229  		resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
   230  		if !hasResourceGroup {
   231  			return fmt.Errorf("Bad: no resource group found in state for virtual machine: scale set %s", name)
   232  		}
   233  
   234  		conn := testAccProvider.Meta().(*ArmClient).vmScaleSetClient
   235  
   236  		_, err := conn.Delete(resourceGroup, name, make(chan struct{}))
   237  		if err != nil {
   238  			return fmt.Errorf("Bad: Delete on vmScaleSetClient: %s", err)
   239  		}
   240  
   241  		return nil
   242  	}
   243  }
   244  
   245  func testCheckAzureRMVirtualMachineScaleSetDestroy(s *terraform.State) error {
   246  	conn := testAccProvider.Meta().(*ArmClient).vmScaleSetClient
   247  
   248  	for _, rs := range s.RootModule().Resources {
   249  		if rs.Type != "azurerm_virtual_machine_scale_set" {
   250  			continue
   251  		}
   252  
   253  		name := rs.Primary.Attributes["name"]
   254  		resourceGroup := rs.Primary.Attributes["resource_group_name"]
   255  
   256  		resp, err := conn.Get(resourceGroup, name)
   257  
   258  		if err != nil {
   259  			return nil
   260  		}
   261  
   262  		if resp.StatusCode != http.StatusNotFound {
   263  			return fmt.Errorf("Virtual Machine Scale Set still exists:\n%#v", resp.VirtualMachineScaleSetProperties)
   264  		}
   265  	}
   266  
   267  	return nil
   268  }
   269  
   270  func testCheckAzureRMVirtualMachineScaleSetHasLoadbalancer(name string) resource.TestCheckFunc {
   271  	return func(s *terraform.State) error {
   272  		// Ensure we have enough information in state to look up in API
   273  		rs, ok := s.RootModule().Resources[name]
   274  		if !ok {
   275  			return fmt.Errorf("Not found: %s", name)
   276  		}
   277  
   278  		name := rs.Primary.Attributes["name"]
   279  		resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
   280  		if !hasResourceGroup {
   281  			return fmt.Errorf("Bad: no resource group found in state for virtual machine: scale set %s", name)
   282  		}
   283  
   284  		conn := testAccProvider.Meta().(*ArmClient).vmScaleSetClient
   285  		resp, err := conn.Get(resourceGroup, name)
   286  		if err != nil {
   287  			return fmt.Errorf("Bad: Get on vmScaleSetClient: %s", err)
   288  		}
   289  
   290  		if resp.StatusCode == http.StatusNotFound {
   291  			return fmt.Errorf("Bad: VirtualMachineScaleSet %q (resource group: %q) does not exist", name, resourceGroup)
   292  		}
   293  
   294  		n := resp.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations
   295  		if n == nil || len(*n) == 0 {
   296  			return fmt.Errorf("Bad: Could not get network interface configurations for scale set %v", name)
   297  		}
   298  
   299  		ip := (*n)[0].IPConfigurations
   300  		if ip == nil || len(*ip) == 0 {
   301  			return fmt.Errorf("Bad: Could not get ip configurations for scale set %v", name)
   302  		}
   303  
   304  		pools := (*ip)[0].LoadBalancerBackendAddressPools
   305  		if pools == nil || len(*pools) == 0 {
   306  			return fmt.Errorf("Bad: Load balancer backend pools is empty for scale set %v", name)
   307  		}
   308  
   309  		return nil
   310  	}
   311  }
   312  
   313  func testCheckAzureRMVirtualMachineScaleSetOverprovision(name string) resource.TestCheckFunc {
   314  	return func(s *terraform.State) error {
   315  		// Ensure we have enough information in state to look up in API
   316  		rs, ok := s.RootModule().Resources[name]
   317  		if !ok {
   318  			return fmt.Errorf("Not found: %s", name)
   319  		}
   320  
   321  		name := rs.Primary.Attributes["name"]
   322  		resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
   323  		if !hasResourceGroup {
   324  			return fmt.Errorf("Bad: no resource group found in state for virtual machine: scale set %s", name)
   325  		}
   326  
   327  		conn := testAccProvider.Meta().(*ArmClient).vmScaleSetClient
   328  		resp, err := conn.Get(resourceGroup, name)
   329  		if err != nil {
   330  			return fmt.Errorf("Bad: Get on vmScaleSetClient: %s", err)
   331  		}
   332  
   333  		if resp.StatusCode == http.StatusNotFound {
   334  			return fmt.Errorf("Bad: VirtualMachineScaleSet %q (resource group: %q) does not exist", name, resourceGroup)
   335  		}
   336  
   337  		if *resp.Overprovision {
   338  			return fmt.Errorf("Bad: Overprovision should have been false for scale set %v", name)
   339  		}
   340  
   341  		return nil
   342  	}
   343  }
   344  
   345  func testCheckAzureRMVirtualMachineScaleSetExtension(name string) resource.TestCheckFunc {
   346  	return func(s *terraform.State) error {
   347  		// Ensure we have enough information in state to look up in API
   348  		rs, ok := s.RootModule().Resources[name]
   349  		if !ok {
   350  			return fmt.Errorf("Not found: %s", name)
   351  		}
   352  
   353  		name := rs.Primary.Attributes["name"]
   354  		resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
   355  		if !hasResourceGroup {
   356  			return fmt.Errorf("Bad: no resource group found in state for virtual machine: scale set %s", name)
   357  		}
   358  
   359  		conn := testAccProvider.Meta().(*ArmClient).vmScaleSetClient
   360  		resp, err := conn.Get(resourceGroup, name)
   361  		if err != nil {
   362  			return fmt.Errorf("Bad: Get on vmScaleSetClient: %s", err)
   363  		}
   364  
   365  		if resp.StatusCode == http.StatusNotFound {
   366  			return fmt.Errorf("Bad: VirtualMachineScaleSet %q (resource group: %q) does not exist", name, resourceGroup)
   367  		}
   368  
   369  		n := resp.VirtualMachineProfile.ExtensionProfile.Extensions
   370  		if n == nil || len(*n) == 0 {
   371  			return fmt.Errorf("Bad: Could not get extensions for scale set %v", name)
   372  		}
   373  
   374  		return nil
   375  	}
   376  }
   377  
   378  var testAccAzureRMVirtualMachineScaleSet_basic = `
   379  resource "azurerm_resource_group" "test" {
   380      name = "acctestRG-%d"
   381      location = "West US 2"
   382  }
   383  
   384  resource "azurerm_virtual_network" "test" {
   385      name = "acctvn-%d"
   386      address_space = ["10.0.0.0/16"]
   387      location = "West US 2"
   388      resource_group_name = "${azurerm_resource_group.test.name}"
   389  }
   390  
   391  resource "azurerm_subnet" "test" {
   392      name = "acctsub-%d"
   393      resource_group_name = "${azurerm_resource_group.test.name}"
   394      virtual_network_name = "${azurerm_virtual_network.test.name}"
   395      address_prefix = "10.0.2.0/24"
   396  }
   397  
   398  resource "azurerm_network_interface" "test" {
   399      name = "acctni-%d"
   400      location = "West US 2"
   401      resource_group_name = "${azurerm_resource_group.test.name}"
   402  
   403      ip_configuration {
   404      	name = "testconfiguration1"
   405      	subnet_id = "${azurerm_subnet.test.id}"
   406      	private_ip_address_allocation = "dynamic"
   407      }
   408  }
   409  
   410  resource "azurerm_storage_account" "test" {
   411      name = "accsa%d"
   412      resource_group_name = "${azurerm_resource_group.test.name}"
   413      location = "West US 2"
   414      account_type = "Standard_LRS"
   415  
   416      tags {
   417          environment = "staging"
   418      }
   419  }
   420  
   421  resource "azurerm_storage_container" "test" {
   422      name = "vhds"
   423      resource_group_name = "${azurerm_resource_group.test.name}"
   424      storage_account_name = "${azurerm_storage_account.test.name}"
   425      container_access_type = "private"
   426  }
   427  
   428  resource "azurerm_virtual_machine_scale_set" "test" {
   429    name = "acctvmss-%d"
   430    location = "West US 2"
   431    resource_group_name = "${azurerm_resource_group.test.name}"
   432    upgrade_policy_mode = "Manual"
   433  
   434    sku {
   435      name = "Standard_D1_v2"
   436      tier = "Standard"
   437      capacity = 2
   438    }
   439  
   440    os_profile {
   441      computer_name_prefix = "testvm-%d"
   442      admin_username = "myadmin"
   443      admin_password = "Passwword1234"
   444    }
   445  
   446    network_profile {
   447        name = "TestNetworkProfile-%d"
   448        primary = true
   449        ip_configuration {
   450          name = "TestIPConfiguration"
   451          subnet_id = "${azurerm_subnet.test.id}"
   452        }
   453    }
   454  
   455    storage_profile_os_disk {
   456      name = "osDiskProfile"
   457      caching       = "ReadWrite"
   458      create_option = "FromImage"
   459      vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"]
   460    }
   461  
   462    storage_profile_image_reference {
   463      publisher = "Canonical"
   464      offer     = "UbuntuServer"
   465      sku       = "16.04-LTS"
   466      version   = "latest"
   467    }
   468  }
   469  `
   470  
   471  func testAccAzureRMVirtualMachineScaleSet_linux(rInt int) string {
   472  	return fmt.Sprintf(`
   473  	resource "azurerm_resource_group" "test" {
   474    name     = "acctestrg-%d"
   475    location = "West Europe"
   476  }
   477  resource "azurerm_virtual_network" "test" {
   478    name                = "acctestvn-%d"
   479    resource_group_name = "${azurerm_resource_group.test.name}"
   480    location            = "${azurerm_resource_group.test.location}"
   481    address_space       = ["10.0.0.0/8"]
   482  }
   483  resource "azurerm_subnet" "test" {
   484    name                 = "acctestsn-%d"
   485    resource_group_name  = "${azurerm_resource_group.test.name}"
   486    virtual_network_name = "${azurerm_virtual_network.test.name}"
   487    address_prefix       = "10.0.1.0/24"
   488  }
   489  resource "azurerm_storage_account" "test" {
   490    name                = "accsa%d"
   491    resource_group_name = "${azurerm_resource_group.test.name}"
   492    location            = "${azurerm_resource_group.test.location}"
   493    account_type        = "Standard_LRS"
   494  }
   495  resource "azurerm_storage_container" "test" {
   496    name                  = "acctestsc-%d"
   497    resource_group_name   = "${azurerm_resource_group.test.name}"
   498    storage_account_name  = "${azurerm_storage_account.test.name}"
   499    container_access_type = "private"
   500  }
   501  resource "azurerm_public_ip" "test" {
   502    name                         = "acctestpip-%d"
   503    resource_group_name          = "${azurerm_resource_group.test.name}"
   504    location                     = "${azurerm_resource_group.test.location}"
   505    public_ip_address_allocation = "static"
   506  }
   507  resource "azurerm_lb" "test" {
   508    name                = "acctestlb-%d"
   509    resource_group_name = "${azurerm_resource_group.test.name}"
   510    location            = "${azurerm_resource_group.test.location}"
   511    frontend_ip_configuration {
   512      name                 = "ip-address"
   513      public_ip_address_id = "${azurerm_public_ip.test.id}"
   514    }
   515  }
   516  resource "azurerm_lb_backend_address_pool" "test" {
   517    name                = "acctestbap-%d"
   518    resource_group_name = "${azurerm_resource_group.test.name}"
   519    loadbalancer_id     = "${azurerm_lb.test.id}"
   520  }
   521  resource "azurerm_virtual_machine_scale_set" "test" {
   522    name                = "acctestvmss-%d"
   523    resource_group_name = "${azurerm_resource_group.test.name}"
   524    location            = "${azurerm_resource_group.test.location}"
   525    upgrade_policy_mode = "Automatic"
   526    sku {
   527      name     = "Standard_A0"
   528      tier     = "Standard"
   529      capacity = "1"
   530    }
   531    os_profile {
   532      computer_name_prefix = "prefix"
   533      admin_username       = "ubuntu"
   534      admin_password       = "password"
   535      custom_data          = "custom data!"
   536    }
   537    os_profile_linux_config {
   538      disable_password_authentication = true
   539      ssh_keys {
   540        path     = "/home/ubuntu/.ssh/authorized_keys"
   541        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"
   542      }
   543    }
   544    network_profile {
   545      name    = "TestNetworkProfile"
   546      primary = true
   547      ip_configuration {
   548        name                                   = "TestIPConfiguration"
   549        subnet_id                              = "${azurerm_subnet.test.id}"
   550        load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"]
   551      }
   552    }
   553    storage_profile_os_disk {
   554      name           = "osDiskProfile"
   555      caching        = "ReadWrite"
   556      create_option  = "FromImage"
   557      os_type        = "linux"
   558      vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"]
   559    }
   560    storage_profile_image_reference {
   561      publisher = "Canonical"
   562      offer     = "UbuntuServer"
   563      sku       = "14.04.2-LTS"
   564      version   = "latest"
   565    }
   566  }
   567  `, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt)
   568  }
   569  
   570  func testAccAzureRMVirtualMachineScaleSet_linuxUpdated(rInt int) string {
   571  	return fmt.Sprintf(`
   572  	resource "azurerm_resource_group" "test" {
   573    name     = "acctestrg-%d"
   574    location = "West Europe"
   575  }
   576  resource "azurerm_virtual_network" "test" {
   577    name                = "acctestvn-%d"
   578    resource_group_name = "${azurerm_resource_group.test.name}"
   579    location            = "${azurerm_resource_group.test.location}"
   580    address_space       = ["10.0.0.0/8"]
   581  }
   582  resource "azurerm_subnet" "test" {
   583    name                 = "acctestsn-%d"
   584    resource_group_name  = "${azurerm_resource_group.test.name}"
   585    virtual_network_name = "${azurerm_virtual_network.test.name}"
   586    address_prefix       = "10.0.1.0/24"
   587  }
   588  resource "azurerm_storage_account" "test" {
   589    name                = "accsa%d"
   590    resource_group_name = "${azurerm_resource_group.test.name}"
   591    location            = "${azurerm_resource_group.test.location}"
   592    account_type        = "Standard_LRS"
   593  }
   594  resource "azurerm_storage_container" "test" {
   595    name                  = "acctestsc-%d"
   596    resource_group_name   = "${azurerm_resource_group.test.name}"
   597    storage_account_name  = "${azurerm_storage_account.test.name}"
   598    container_access_type = "private"
   599  }
   600  resource "azurerm_public_ip" "test" {
   601    name                         = "acctestpip-%d"
   602    resource_group_name          = "${azurerm_resource_group.test.name}"
   603    location                     = "${azurerm_resource_group.test.location}"
   604    public_ip_address_allocation = "static"
   605  }
   606  resource "azurerm_lb" "test" {
   607    name                = "acctestlb-%d"
   608    resource_group_name = "${azurerm_resource_group.test.name}"
   609    location            = "${azurerm_resource_group.test.location}"
   610    frontend_ip_configuration {
   611      name                 = "ip-address"
   612      public_ip_address_id = "${azurerm_public_ip.test.id}"
   613    }
   614  }
   615  resource "azurerm_lb_backend_address_pool" "test" {
   616    name                = "acctestbap-%d"
   617    resource_group_name = "${azurerm_resource_group.test.name}"
   618    loadbalancer_id     = "${azurerm_lb.test.id}"
   619  }
   620  resource "azurerm_virtual_machine_scale_set" "test" {
   621    name                = "acctestvmss-%d"
   622    resource_group_name = "${azurerm_resource_group.test.name}"
   623    location            = "${azurerm_resource_group.test.location}"
   624    upgrade_policy_mode = "Automatic"
   625    sku {
   626      name     = "Standard_A0"
   627      tier     = "Standard"
   628      capacity = "1"
   629    }
   630    os_profile {
   631      computer_name_prefix = "prefix"
   632      admin_username       = "ubuntu"
   633      admin_password       = "password"
   634      custom_data          = "custom data!"
   635    }
   636    os_profile_linux_config {
   637      disable_password_authentication = true
   638      ssh_keys {
   639        path     = "/home/ubuntu/.ssh/authorized_keys"
   640        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"
   641      }
   642    }
   643    network_profile {
   644      name    = "TestNetworkProfile"
   645      primary = true
   646      ip_configuration {
   647        name                                   = "TestIPConfiguration"
   648        subnet_id                              = "${azurerm_subnet.test.id}"
   649        load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"]
   650      }
   651    }
   652    storage_profile_os_disk {
   653      name           = "osDiskProfile"
   654      caching        = "ReadWrite"
   655      create_option  = "FromImage"
   656      os_type        = "linux"
   657      vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"]
   658    }
   659    storage_profile_image_reference {
   660      publisher = "Canonical"
   661      offer     = "UbuntuServer"
   662      sku       = "14.04.2-LTS"
   663      version   = "latest"
   664    }
   665    tags {
   666      ThisIs = "a test"
   667    }
   668  }
   669  `, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt, rInt)
   670  }
   671  
   672  var testAccAzureRMVirtualMachineScaleSet_basicLinux_managedDisk = `
   673  resource "azurerm_resource_group" "test" {
   674      name = "acctestRG-%d"
   675      location = "West US 2"
   676  }
   677  
   678  resource "azurerm_virtual_network" "test" {
   679      name = "acctvn-%d"
   680      address_space = ["10.0.0.0/16"]
   681      location = "West US 2"
   682      resource_group_name = "${azurerm_resource_group.test.name}"
   683  }
   684  
   685  resource "azurerm_subnet" "test" {
   686      name = "acctsub-%d"
   687      resource_group_name = "${azurerm_resource_group.test.name}"
   688      virtual_network_name = "${azurerm_virtual_network.test.name}"
   689      address_prefix = "10.0.2.0/24"
   690  }
   691  
   692  resource "azurerm_virtual_machine_scale_set" "test" {
   693    name = "acctvmss-%d"
   694    location = "West US 2"
   695    resource_group_name = "${azurerm_resource_group.test.name}"
   696    upgrade_policy_mode = "Manual"
   697  
   698    sku {
   699      name = "Standard_D1_v2"
   700      tier = "Standard"
   701      capacity = 2
   702    }
   703  
   704    os_profile {
   705      computer_name_prefix = "testvm-%d"
   706      admin_username = "myadmin"
   707      admin_password = "Passwword1234"
   708    }
   709  
   710    network_profile {
   711        name = "TestNetworkProfile-%d"
   712        primary = true
   713        ip_configuration {
   714          name = "TestIPConfiguration"
   715          subnet_id = "${azurerm_subnet.test.id}"
   716        }
   717    }
   718  
   719    storage_profile_os_disk {
   720  	name 		  = ""
   721      caching       = "ReadWrite"
   722      create_option = "FromImage"
   723      managed_disk_type = "Standard_LRS"
   724    }
   725  
   726    storage_profile_image_reference {
   727      publisher = "Canonical"
   728      offer     = "UbuntuServer"
   729      sku       = "16.04-LTS"
   730      version   = "latest"
   731    }
   732  }
   733  `
   734  
   735  var testAccAzureRMVirtualMachineScaleSetLoadbalancerTemplate = `
   736  resource "azurerm_resource_group" "test" {
   737      name 	 = "acctestrg-%d"
   738      location = "southcentralus"
   739  }
   740  
   741  resource "azurerm_virtual_network" "test" {
   742      name 		        = "acctvn-%d"
   743      address_space       = ["10.0.0.0/16"]
   744      location            = "southcentralus"
   745      resource_group_name = "${azurerm_resource_group.test.name}"
   746  }
   747  
   748  resource "azurerm_subnet" "test" {
   749      name                 = "acctsub-%d"
   750      resource_group_name  = "${azurerm_resource_group.test.name}"
   751      virtual_network_name = "${azurerm_virtual_network.test.name}"
   752      address_prefix       = "10.0.2.0/24"
   753  }
   754  
   755  resource "azurerm_storage_account" "test" {
   756      name                = "accsa%d"
   757      resource_group_name = "${azurerm_resource_group.test.name}"
   758      location            = "southcentralus"
   759      account_type        = "Standard_LRS"
   760  }
   761  
   762  resource "azurerm_storage_container" "test" {
   763      name                  = "vhds"
   764      resource_group_name   = "${azurerm_resource_group.test.name}"
   765      storage_account_name  = "${azurerm_storage_account.test.name}"
   766      container_access_type = "private"
   767  }
   768  
   769  resource "azurerm_lb" "test" {
   770      name                = "acctestlb-%d"
   771      location            = "southcentralus"
   772      resource_group_name = "${azurerm_resource_group.test.name}"
   773  
   774      frontend_ip_configuration {
   775          name                          = "default"
   776          subnet_id                     = "${azurerm_subnet.test.id}"
   777          private_ip_address_allocation = "Dynamic"
   778      }
   779  }
   780  
   781  resource "azurerm_lb_backend_address_pool" "test" {
   782      name                = "test"
   783      resource_group_name = "${azurerm_resource_group.test.name}"
   784      location            = "southcentralus"
   785      loadbalancer_id     = "${azurerm_lb.test.id}"
   786  }
   787  
   788  resource "azurerm_lb_nat_pool" "test" {
   789    resource_group_name = "${azurerm_resource_group.test.name}"
   790    name                           = "ssh"
   791    loadbalancer_id                = "${azurerm_lb.test.id}"
   792    protocol                       = "Tcp"
   793    frontend_port_start            = 50000
   794    frontend_port_end              = 50119
   795    backend_port                   = 22
   796    frontend_ip_configuration_name = "default"
   797  }
   798  
   799  resource "azurerm_virtual_machine_scale_set" "test" {
   800    	name                = "acctvmss-%d"
   801    	location            = "southcentralus"
   802    	resource_group_name = "${azurerm_resource_group.test.name}"
   803    	upgrade_policy_mode = "Manual"
   804  
   805    	sku {
   806  		name     = "Standard_D1_v2"
   807      	tier     = "Standard"
   808      	capacity = 1
   809  	}
   810  
   811    	os_profile {
   812      	computer_name_prefix = "testvm-%d"
   813      	admin_username = "myadmin"
   814      	admin_password = "Passwword1234"
   815    	}
   816  
   817    	network_profile {
   818        	name    = "TestNetworkProfile"
   819        	primary = true
   820        	ip_configuration {
   821          	name                                   = "TestIPConfiguration"
   822          	subnet_id                              = "${azurerm_subnet.test.id}"
   823  			load_balancer_backend_address_pool_ids = [ "${azurerm_lb_backend_address_pool.test.id}" ]
   824  		    load_balancer_inbound_nat_rules_ids = ["${azurerm_lb_nat_pool.test.id}"]
   825        	}
   826    	}
   827  
   828    	storage_profile_os_disk {
   829      	name 		   = "os-disk"
   830      	caching        = "ReadWrite"
   831      	create_option  = "FromImage"
   832      	vhd_containers = [ "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}" ]
   833    	}
   834  
   835    	storage_profile_image_reference {
   836      	publisher = "Canonical"
   837      	offer     = "UbuntuServer"
   838      	sku       = "16.04-LTS"
   839      	version   = "latest"
   840    	}
   841  }
   842  `
   843  
   844  var testAccAzureRMVirtualMachineScaleSetOverprovisionTemplate = `
   845  resource "azurerm_resource_group" "test" {
   846      name 	 = "acctestrg-%d"
   847      location = "southcentralus"
   848  }
   849  
   850  resource "azurerm_virtual_network" "test" {
   851      name 		        = "acctvn-%d"
   852      address_space       = ["10.0.0.0/16"]
   853      location            = "southcentralus"
   854      resource_group_name = "${azurerm_resource_group.test.name}"
   855  }
   856  
   857  resource "azurerm_subnet" "test" {
   858      name                 = "acctsub-%d"
   859      resource_group_name  = "${azurerm_resource_group.test.name}"
   860      virtual_network_name = "${azurerm_virtual_network.test.name}"
   861      address_prefix       = "10.0.2.0/24"
   862  }
   863  
   864  resource "azurerm_storage_account" "test" {
   865      name                = "accsa%d"
   866      resource_group_name = "${azurerm_resource_group.test.name}"
   867      location            = "southcentralus"
   868      account_type        = "Standard_LRS"
   869  }
   870  
   871  resource "azurerm_storage_container" "test" {
   872      name                  = "vhds"
   873      resource_group_name   = "${azurerm_resource_group.test.name}"
   874      storage_account_name  = "${azurerm_storage_account.test.name}"
   875      container_access_type = "private"
   876  }
   877  
   878  resource "azurerm_virtual_machine_scale_set" "test" {
   879    	name                = "acctvmss-%d"
   880    	location            = "southcentralus"
   881    	resource_group_name = "${azurerm_resource_group.test.name}"
   882    	upgrade_policy_mode = "Manual"
   883  	overprovision       = false
   884  
   885    	sku {
   886  		name     = "Standard_D1_v2"
   887      	tier     = "Standard"
   888      	capacity = 1
   889  	}
   890  
   891    	os_profile {
   892      	computer_name_prefix = "testvm-%d"
   893      	admin_username = "myadmin"
   894      	admin_password = "Passwword1234"
   895    	}
   896  
   897    	network_profile {
   898        	name    = "TestNetworkProfile"
   899        	primary = true
   900        	ip_configuration {
   901          	name	  = "TestIPConfiguration"
   902          	subnet_id = "${azurerm_subnet.test.id}"
   903        	}
   904    	}
   905  
   906    	storage_profile_os_disk {
   907      	name 		   = "os-disk"
   908      	caching        = "ReadWrite"
   909      	create_option  = "FromImage"
   910      	vhd_containers = [ "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}" ]
   911    	}
   912  
   913    	storage_profile_image_reference {
   914      	publisher = "Canonical"
   915      	offer     = "UbuntuServer"
   916      	sku       = "16.04-LTS"
   917      	version   = "latest"
   918    	}
   919  }
   920  `
   921  
   922  var testAccAzureRMVirtualMachineScaleSetExtensionTemplate = `
   923  resource "azurerm_resource_group" "test" {
   924      name 	 = "acctestrg-%d"
   925      location = "southcentralus"
   926  }
   927  
   928  resource "azurerm_virtual_network" "test" {
   929      name 		        = "acctvn-%d"
   930      address_space       = ["10.0.0.0/16"]
   931      location            = "southcentralus"
   932      resource_group_name = "${azurerm_resource_group.test.name}"
   933  }
   934  
   935  resource "azurerm_subnet" "test" {
   936      name                 = "acctsub-%d"
   937      resource_group_name  = "${azurerm_resource_group.test.name}"
   938      virtual_network_name = "${azurerm_virtual_network.test.name}"
   939      address_prefix       = "10.0.2.0/24"
   940  }
   941  
   942  resource "azurerm_storage_account" "test" {
   943      name                = "accsa%d"
   944      resource_group_name = "${azurerm_resource_group.test.name}"
   945      location            = "southcentralus"
   946      account_type        = "Standard_LRS"
   947  }
   948  
   949  resource "azurerm_storage_container" "test" {
   950      name                  = "vhds"
   951      resource_group_name   = "${azurerm_resource_group.test.name}"
   952      storage_account_name  = "${azurerm_storage_account.test.name}"
   953      container_access_type = "private"
   954  }
   955  
   956  resource "azurerm_virtual_machine_scale_set" "test" {
   957    	name                = "acctvmss-%d"
   958    	location            = "southcentralus"
   959    	resource_group_name = "${azurerm_resource_group.test.name}"
   960    	upgrade_policy_mode = "Manual"
   961  	overprovision       = false
   962  
   963    	sku {
   964  		name     = "Standard_D1_v2"
   965      	tier     = "Standard"
   966      	capacity = 1
   967  	}
   968  
   969    	os_profile {
   970      	computer_name_prefix = "testvm-%d"
   971      	admin_username = "myadmin"
   972      	admin_password = "Passwword1234"
   973    	}
   974  
   975    	network_profile {
   976        	name    = "TestNetworkProfile"
   977        	primary = true
   978        	ip_configuration {
   979          	name	  = "TestIPConfiguration"
   980          	subnet_id = "${azurerm_subnet.test.id}"
   981        	}
   982    	}
   983  
   984    	storage_profile_os_disk {
   985      	name 		   = "os-disk"
   986      	caching        = "ReadWrite"
   987      	create_option  = "FromImage"
   988      	vhd_containers = [ "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}" ]
   989    	}
   990  
   991    	storage_profile_image_reference {
   992      	publisher = "Canonical"
   993      	offer     = "UbuntuServer"
   994      	sku       = "16.04-LTS"
   995      	version   = "latest"
   996    	}
   997  
   998  	extension {
   999  		name                       = "CustomScript"
  1000  		publisher                  = "Microsoft.Azure.Extensions"
  1001  		type                       = "CustomScript"
  1002  		type_handler_version       = "2.0"
  1003  		auto_upgrade_minor_version = true
  1004  		settings                   = <<SETTINGS
  1005  		{
  1006  			"commandToExecute": "echo $HOSTNAME"
  1007  		}
  1008  SETTINGS
  1009  
  1010  		protected_settings         = <<SETTINGS
  1011  		{
  1012  			"storageAccountName": "${azurerm_storage_account.test.name}",
  1013  			"storageAccountKey": "${azurerm_storage_account.test.primary_access_key}"
  1014  		}
  1015  SETTINGS
  1016  	}
  1017  }
  1018  `
  1019  
  1020  var testAccAzureRMVirtualMachineScaleSetMultipleExtensionsTemplate = `
  1021  resource "azurerm_resource_group" "test" {
  1022      name 	 = "acctestrg-%d"
  1023      location = "southcentralus"
  1024  }
  1025  
  1026  resource "azurerm_virtual_network" "test" {
  1027      name 		        = "acctvn-%d"
  1028      address_space       = ["10.0.0.0/16"]
  1029      location            = "southcentralus"
  1030      resource_group_name = "${azurerm_resource_group.test.name}"
  1031  }
  1032  
  1033  resource "azurerm_subnet" "test" {
  1034      name                 = "acctsub-%d"
  1035      resource_group_name  = "${azurerm_resource_group.test.name}"
  1036      virtual_network_name = "${azurerm_virtual_network.test.name}"
  1037      address_prefix       = "10.0.2.0/24"
  1038  }
  1039  
  1040  resource "azurerm_storage_account" "test" {
  1041      name                = "accsa%d"
  1042      resource_group_name = "${azurerm_resource_group.test.name}"
  1043      location            = "southcentralus"
  1044      account_type        = "Standard_LRS"
  1045  }
  1046  
  1047  resource "azurerm_storage_container" "test" {
  1048      name                  = "vhds"
  1049      resource_group_name   = "${azurerm_resource_group.test.name}"
  1050      storage_account_name  = "${azurerm_storage_account.test.name}"
  1051      container_access_type = "private"
  1052  }
  1053  
  1054  resource "azurerm_virtual_machine_scale_set" "test" {
  1055    	name                = "acctvmss-%d"
  1056    	location            = "southcentralus"
  1057    	resource_group_name = "${azurerm_resource_group.test.name}"
  1058    	upgrade_policy_mode = "Manual"
  1059  	overprovision       = false
  1060  
  1061    	sku {
  1062  		name     = "Standard_D1_v2"
  1063      	tier     = "Standard"
  1064      	capacity = 1
  1065  	}
  1066  
  1067    	os_profile {
  1068      	computer_name_prefix = "testvm-%d"
  1069      	admin_username = "myadmin"
  1070      	admin_password = "Passwword1234"
  1071    	}
  1072  
  1073    	network_profile {
  1074        	name    = "TestNetworkProfile"
  1075        	primary = true
  1076        	ip_configuration {
  1077          	name	  = "TestIPConfiguration"
  1078          	subnet_id = "${azurerm_subnet.test.id}"
  1079        	}
  1080    	}
  1081  
  1082    	storage_profile_os_disk {
  1083      	name 		   = "os-disk"
  1084      	caching        = "ReadWrite"
  1085      	create_option  = "FromImage"
  1086      	vhd_containers = [ "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}" ]
  1087    	}
  1088  
  1089    	storage_profile_image_reference {
  1090      	publisher = "Canonical"
  1091      	offer     = "UbuntuServer"
  1092      	sku       = "16.04-LTS"
  1093      	version   = "latest"
  1094    	}
  1095  
  1096  	extension {
  1097  		name                       = "CustomScript"
  1098  		publisher                  = "Microsoft.Azure.Extensions"
  1099  		type                       = "CustomScript"
  1100  		type_handler_version       = "2.0"
  1101  		auto_upgrade_minor_version = true
  1102  		settings                   = <<SETTINGS
  1103  		{
  1104  			"commandToExecute": "echo $HOSTNAME"
  1105  		}
  1106  SETTINGS
  1107  
  1108  		protected_settings         = <<SETTINGS
  1109  		{
  1110  			"storageAccountName": "${azurerm_storage_account.test.name}",
  1111  			"storageAccountKey": "${azurerm_storage_account.test.primary_access_key}"
  1112  		}
  1113  SETTINGS
  1114  	}
  1115  
  1116  	extension {
  1117  		name                       = "Docker"
  1118  		publisher                  = "Microsoft.Azure.Extensions"
  1119  		type                       = "DockerExtension"
  1120  		type_handler_version       = "1.0"
  1121  		auto_upgrade_minor_version = true
  1122  	}
  1123  }
  1124  `
  1125  
  1126  var testAccAzureRMVirtualMachineScaleSet_osDiskTypeConflict = `
  1127  resource "azurerm_resource_group" "test" {
  1128      name = "acctestRG-%d"
  1129      location = "West US 2"
  1130  }
  1131  
  1132  resource "azurerm_virtual_network" "test" {
  1133      name = "acctvn-%d"
  1134      address_space = ["10.0.0.0/16"]
  1135      location = "West US 2"
  1136      resource_group_name = "${azurerm_resource_group.test.name}"
  1137  }
  1138  
  1139  resource "azurerm_subnet" "test" {
  1140      name = "acctsub-%d"
  1141      resource_group_name = "${azurerm_resource_group.test.name}"
  1142      virtual_network_name = "${azurerm_virtual_network.test.name}"
  1143      address_prefix = "10.0.2.0/24"
  1144  }
  1145  
  1146  resource "azurerm_network_interface" "test" {
  1147      name = "acctni-%d"
  1148      location = "West US 2"
  1149      resource_group_name = "${azurerm_resource_group.test.name}"
  1150  
  1151      ip_configuration {
  1152      	name = "testconfiguration1"
  1153      	subnet_id = "${azurerm_subnet.test.id}"
  1154      	private_ip_address_allocation = "dynamic"
  1155      }
  1156  }
  1157  
  1158  resource "azurerm_virtual_machine_scale_set" "test" {
  1159    name = "acctvmss-%d"
  1160    location = "West US 2"
  1161    resource_group_name = "${azurerm_resource_group.test.name}"
  1162    upgrade_policy_mode = "Manual"
  1163  
  1164    sku {
  1165      name = "Standard_D1_v2"
  1166      tier = "Standard"
  1167      capacity = 2
  1168    }
  1169  
  1170    os_profile {
  1171      computer_name_prefix = "testvm-%d"
  1172      admin_username = "myadmin"
  1173      admin_password = "Passwword1234"
  1174    }
  1175  
  1176    network_profile {
  1177        name = "TestNetworkProfile-%d"
  1178        primary = true
  1179        ip_configuration {
  1180          name = "TestIPConfiguration"
  1181          subnet_id = "${azurerm_subnet.test.id}"
  1182        }
  1183    }
  1184  
  1185    storage_profile_os_disk {
  1186  	name 		  = ""
  1187      caching       = "ReadWrite"
  1188      create_option = "FromImage"
  1189      managed_disk_type = "Standard_LRS"
  1190      vhd_containers = ["should_cause_conflict"]
  1191    }
  1192  
  1193    storage_profile_image_reference {
  1194      publisher = "Canonical"
  1195      offer     = "UbuntuServer"
  1196      sku       = "16.04-LTS"
  1197      version   = "latest"
  1198    }
  1199  }
  1200  `