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