From b7b3f4e270cca42b1152f318f582336b63d78092 Mon Sep 17 00:00:00 2001 From: Nick Chapman Date: Tue, 2 Oct 2018 16:10:40 +0100 Subject: [PATCH 01/11] Added option to set the application security group of a scale set instance --- .../resource_arm_virtual_machine_scale_set.go | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index 005d0691eede..9fffebf2bc7d 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -379,6 +379,13 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { Set: schema.HashString, }, + "application_security_group_ids": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + }, + "load_balancer_backend_address_pool_ids": { Type: schema.TypeSet, Optional: true, @@ -738,12 +745,12 @@ func resourceArmVirtualMachineScaleSetCreate(d *schema.ResourceData, meta interf } properties := compute.VirtualMachineScaleSet{ - Name: &name, - Location: &location, - Tags: expandTags(tags), - Sku: sku, + Name: &name, + Location: &location, + Tags: expandTags(tags), + Sku: sku, VirtualMachineScaleSetProperties: &scaleSetProps, - Zones: zones, + Zones: zones, } if _, ok := d.GetOk("identity"); ok { @@ -1142,6 +1149,14 @@ func flattenAzureRmVirtualMachineScaleSetNetworkProfile(profile *compute.Virtual } config["application_gateway_backend_address_pool_ids"] = schema.NewSet(schema.HashString, addressPools) + applicationSecurityGroups := make([]interface{}, 0) + if properties.ApplicationSecurityGroups != nil { + for _, asg := range *properties.ApplicationSecurityGroups { + applicationSecurityGroups = append(applicationSecurityGroups, *asg.ID) + } + } + config["application_security_group_ids"] = schema.NewSet(schema.HashString, applicationSecurityGroups) + if properties.LoadBalancerBackendAddressPools != nil { addressPools := make([]interface{}, 0, len(*properties.LoadBalancerBackendAddressPools)) for _, pool := range *properties.LoadBalancerBackendAddressPools { @@ -1503,6 +1518,18 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) * ipConfiguration.ApplicationGatewayBackendAddressPools = &resources } + if v := ipconfig["application_security_group_ids"]; v != nil { + asgs := v.(*schema.Set).List() + resources := make([]compute.SubResource, 0, len(asgs)) + for _, p := range asgs { + id := p.(string) + resources = append(resources, compute.SubResource{ + ID: &id, + }) + } + ipConfiguration.ApplicationSecurityGroups = &resources + } + if v := ipconfig["load_balancer_backend_address_pool_ids"]; v != nil { pools := v.(*schema.Set).List() resources := make([]compute.SubResource, 0, len(pools)) From 8fe29de3c88ce33616f726a0d1ca4d815c5936bc Mon Sep 17 00:00:00 2001 From: Nick Chapman Date: Wed, 3 Oct 2018 10:39:23 +0100 Subject: [PATCH 02/11] Fixed formatting change --- azurerm/resource_arm_virtual_machine_scale_set.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index 9fffebf2bc7d..b38647d144b8 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -745,12 +745,12 @@ func resourceArmVirtualMachineScaleSetCreate(d *schema.ResourceData, meta interf } properties := compute.VirtualMachineScaleSet{ - Name: &name, - Location: &location, - Tags: expandTags(tags), - Sku: sku, + Name: &name, + Location: &location, + Tags: expandTags(tags), + Sku: sku, VirtualMachineScaleSetProperties: &scaleSetProps, - Zones: zones, + Zones: zones, } if _, ok := d.GetOk("identity"); ok { From 8ffd276e04bcf677b6ea165ddfb332d23932c10f Mon Sep 17 00:00:00 2001 From: Nick Chapman Date: Wed, 3 Oct 2018 11:14:25 +0100 Subject: [PATCH 03/11] Fixed formatting change --- azurerm/resource_arm_virtual_machine_scale_set.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index b38647d144b8..9fffebf2bc7d 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -745,12 +745,12 @@ func resourceArmVirtualMachineScaleSetCreate(d *schema.ResourceData, meta interf } properties := compute.VirtualMachineScaleSet{ - Name: &name, - Location: &location, - Tags: expandTags(tags), - Sku: sku, + Name: &name, + Location: &location, + Tags: expandTags(tags), + Sku: sku, VirtualMachineScaleSetProperties: &scaleSetProps, - Zones: zones, + Zones: zones, } if _, ok := d.GetOk("identity"); ok { From 6615fdf7c81717c9695f498c11488500594e2a03 Mon Sep 17 00:00:00 2001 From: Nick Chapman Date: Wed, 3 Oct 2018 12:16:06 +0100 Subject: [PATCH 04/11] Fixed formatting change --- GNUmakefile | 2 +- azurerm/resource_arm_virtual_machine_scale_set.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 203a0fd71fca..1ba5dba5bb44 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -36,7 +36,7 @@ vet: fi fmt: - gofmt -w $(GOFMT_FILES) + ~/Downloads/go/bin/gofmt -w $(GOFMT_FILES) fmtcheck: @sh "$(CURDIR)/scripts/gofmtcheck.sh" diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index 9fffebf2bc7d..d57aab3414df 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -745,12 +745,12 @@ func resourceArmVirtualMachineScaleSetCreate(d *schema.ResourceData, meta interf } properties := compute.VirtualMachineScaleSet{ - Name: &name, - Location: &location, - Tags: expandTags(tags), - Sku: sku, + Name: &name, + Location: &location, + Tags: expandTags(tags), + Sku: sku, VirtualMachineScaleSetProperties: &scaleSetProps, - Zones: zones, + Zones: zones, } if _, ok := d.GetOk("identity"); ok { From aa064309f1ffdca92c164b91f57b3e7ba3f8ce9a Mon Sep 17 00:00:00 2001 From: Nick Chapman Date: Wed, 3 Oct 2018 13:31:03 +0100 Subject: [PATCH 05/11] Remove gofmt path override --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 1ba5dba5bb44..203a0fd71fca 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -36,7 +36,7 @@ vet: fi fmt: - ~/Downloads/go/bin/gofmt -w $(GOFMT_FILES) + gofmt -w $(GOFMT_FILES) fmtcheck: @sh "$(CURDIR)/scripts/gofmtcheck.sh" From 501773de5d20b9a14665d9bbcfaf92a51d7f4a98 Mon Sep 17 00:00:00 2001 From: Nick Chapman Date: Wed, 3 Oct 2018 23:40:40 +0100 Subject: [PATCH 06/11] Added test --- ...urce_arm_virtual_machine_scale_set_test.go | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index 624279c753e9..b6e7bc71082b 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -85,6 +85,26 @@ func TestAccAzureRMVirtualMachineScaleSet_basicPublicIP(t *testing.T) { }) } +func TestAccAzureRMVirtualMachineScaleSet_basicApplicationSecurity(t *testing.T) { + resourceName := "azurerm_virtual_machine_scale_set.test" + ri := acctest.RandInt() + config := testAccAzureRMVirtualMachineScaleSet_basicApplicationSecurity(ri, testLocation()) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMVirtualMachineScaleSetDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMVirtualMachineScaleSetExists(resourceName), + testCheckAzureRMVirtualMachineScaleSetApplicationSecurity(resourceName), + ), + }, + }, + }) +} + func TestAccAzureRMVirtualMachineScaleSet_basicAcceleratedNetworking(t *testing.T) { resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() @@ -1000,6 +1020,32 @@ func testCheckAzureRMVirtualMachineScaleSetPublicIPName(name, publicIPName strin } } +func testCheckAzureRMVirtualMachineScaleSetApplicationSecurity(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + resp, err := testGetAzureRMVirtualMachineScaleSet(s, name) + if err != nil { + return err + } + + n := resp.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations + if n == nil || len(*n) == 0 { + return fmt.Errorf("Bad: Could not get network interface configurations for scale set %v", name) + } + + ip := (*n)[0].IPConfigurations + if ip == nil || len(*ip) == 0 { + return fmt.Errorf("Bad: Could not get ip configurations for scale set %v", name) + } + + asgs := (*ip)[0].ApplicationSecurityGroups + if asgs == nil || len(*asgs) == 0 { + return fmt.Errorf("Bad: Application Security Groups was empty for scale set %v", name) + } + + return nil + } +} + func testCheckAzureRMVirtualMachineScaleSetAcceleratedNetworking(name string, boolean bool) resource.TestCheckFunc { return func(s *terraform.State) error { resp, err := testGetAzureRMVirtualMachineScaleSet(s, name) @@ -1360,6 +1406,97 @@ resource "azurerm_virtual_machine_scale_set" "test" { `, rInt, location) } +func testAccAzureRMVirtualMachineScaleSet_basicApplicationSecurity(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctvn-%[1]d" + address_space = ["10.0.0.0/16"] + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_subnet" "test" { + name = "acctsub-%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.2.0/24" +} + +resource "azurerm_application_security_group" "test" { + location = "${azurerm_resource_group.test.location}" + name = "TestApplicationSecurityGroup" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_storage_account" "test" { + name = "accsa%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_tier = "Standard" + account_replication_type = "LRS" + + tags { + environment = "staging" + } +} + +resource "azurerm_storage_container" "test" { + name = "vhds" + resource_group_name = "${azurerm_resource_group.test.name}" + storage_account_name = "${azurerm_storage_account.test.name}" + container_access_type = "private" +} + +resource "azurerm_virtual_machine_scale_set" "test" { + name = "acctvmss-%[1]d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + upgrade_policy_mode = "Manual" + + sku { + name = "Standard_D1_v2" + tier = "Standard" + capacity = 1 + } + + os_profile { + computer_name_prefix = "testvm-%[1]d" + admin_username = "myadmin" + admin_password = "Passwword1234" + } + + network_profile { + name = "TestNetworkProfile-%[1]d" + primary = true + ip_configuration { + name = "TestIPConfiguration" + subnet_id = "${azurerm_subnet.test.id}" + application_security_group_ids = ["${azurerm_application_security_group.test.id}"] + } + } + + storage_profile_os_disk { + name = "osDiskProfile" + caching = "ReadWrite" + create_option = "FromImage" + vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"] + } + + storage_profile_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "16.04-LTS" + version = "latest" + } +} +`, rInt, location) +} + func testAccAzureRMVirtualMachineScaleSet_basicAcceleratedNetworking(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { From 7371221ace1198f1e23e3a93da4caa31220b4024 Mon Sep 17 00:00:00 2001 From: Nick Chapman Date: Wed, 10 Oct 2018 16:22:27 +0100 Subject: [PATCH 07/11] Updated documentation --- website/docs/r/virtual_machine_scale_set.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/virtual_machine_scale_set.html.markdown b/website/docs/r/virtual_machine_scale_set.html.markdown index 02c189f56d2e..88240dfab83b 100644 --- a/website/docs/r/virtual_machine_scale_set.html.markdown +++ b/website/docs/r/virtual_machine_scale_set.html.markdown @@ -376,6 +376,7 @@ output "principal_id" { * `load_balancer_inbound_nat_rules_ids` - (Optional) Specifies an array of references to inbound NAT rules for load balancers. * `primary` - (Optional) Specifies if this ip_configuration is the primary one. * `public_ip_address_configuration` - (Optional) describes a virtual machines scale set IP Configuration's +* `application_security_group_ids` - (Optional) Specifies an array of references to application security groups PublicIPAddress configuration. The public_ip_address_configuration is documented below. `public_ip_address_configuration` supports the following: From ba2a874e48e59221c5b721f8a7f5ae0b414a07eb Mon Sep 17 00:00:00 2001 From: Nick Chapman Date: Tue, 16 Oct 2018 16:29:23 +0100 Subject: [PATCH 08/11] Updated following PR comments --- azurerm/resource_arm_virtual_machine_scale_set.go | 6 +++++- .../resource_arm_virtual_machine_scale_set_test.go | 11 ++++++----- .../docs/r/virtual_machine_scale_set.html.markdown | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index d57aab3414df..e13e7a1b8563 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -382,8 +382,12 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { "application_security_group_ids": { Type: schema.TypeSet, Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: azure.ValidateResourceID, + }, Set: schema.HashString, + MaxItems: 20, }, "load_balancer_backend_address_pool_ids": { diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index b6e7bc71082b..5c135cb164de 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -88,6 +88,9 @@ func TestAccAzureRMVirtualMachineScaleSet_basicPublicIP(t *testing.T) { func TestAccAzureRMVirtualMachineScaleSet_basicApplicationSecurity(t *testing.T) { resourceName := "azurerm_virtual_machine_scale_set.test" ri := acctest.RandInt() + networkProfileName := fmt.Sprintf("TestNetworkProfile-%d", ri) + networkProfile := map[string]interface{}{"name": networkProfileName, "primary": true} + networkProfileHash := fmt.Sprintf("%d", resourceArmVirtualMachineScaleSetNetworkConfigurationHash(networkProfile)) config := testAccAzureRMVirtualMachineScaleSet_basicApplicationSecurity(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -96,10 +99,8 @@ func TestAccAzureRMVirtualMachineScaleSet_basicApplicationSecurity(t *testing.T) Steps: []resource.TestStep{ { Config: config, - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMVirtualMachineScaleSetExists(resourceName), - testCheckAzureRMVirtualMachineScaleSetApplicationSecurity(resourceName), - ), + Check: resource.TestCheckResourceAttr(resourceName, + "network_profile."+networkProfileHash+".ip_configuration.0.application_security_group_ids.#", "1"), }, }, }) @@ -1476,7 +1477,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" subnet_id = "${azurerm_subnet.test.id}" - application_security_group_ids = ["${azurerm_application_security_group.test.id}"] + application_security_group_ids = ["${azurerm_application_security_group.test.id}"] } } diff --git a/website/docs/r/virtual_machine_scale_set.html.markdown b/website/docs/r/virtual_machine_scale_set.html.markdown index 88240dfab83b..47f4bb789a8b 100644 --- a/website/docs/r/virtual_machine_scale_set.html.markdown +++ b/website/docs/r/virtual_machine_scale_set.html.markdown @@ -375,8 +375,8 @@ output "principal_id" { * `load_balancer_backend_address_pool_ids` - (Optional) Specifies an array of references to backend address pools of load balancers. A scale set can reference backend address pools of one public and one internal load balancer. Multiple scale sets cannot use the same load balancer. * `load_balancer_inbound_nat_rules_ids` - (Optional) Specifies an array of references to inbound NAT rules for load balancers. * `primary` - (Optional) Specifies if this ip_configuration is the primary one. -* `public_ip_address_configuration` - (Optional) describes a virtual machines scale set IP Configuration's * `application_security_group_ids` - (Optional) Specifies an array of references to application security groups +* `public_ip_address_configuration` - (Optional) describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. The public_ip_address_configuration is documented below. `public_ip_address_configuration` supports the following: From 1b6fdd661c10dc1c8731192445b5f4c7756fe7a8 Mon Sep 17 00:00:00 2001 From: kt Date: Fri, 26 Oct 2018 12:21:54 -0700 Subject: [PATCH 09/11] fix VMSS crash points --- .../resource_arm_virtual_machine_scale_set.go | 93 ++++++++++--------- .../r/virtual_machine_scale_set.html.markdown | 5 +- 2 files changed, 53 insertions(+), 45 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index a7d7a04111fb..edd155530e5e 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -1139,59 +1139,68 @@ func flattenAzureRmVirtualMachineScaleSetNetworkProfile(profile *compute.Virtual config := make(map[string]interface{}) config["name"] = *ipConfig.Name - properties := ipConfig.VirtualMachineScaleSetIPConfigurationProperties + if properties := ipConfig.VirtualMachineScaleSetIPConfigurationProperties; properties != nil { - if ipConfig.VirtualMachineScaleSetIPConfigurationProperties.Subnet != nil { - config["subnet_id"] = *properties.Subnet.ID - } - - addressPools := make([]interface{}, 0) - if properties.ApplicationGatewayBackendAddressPools != nil { - for _, pool := range *properties.ApplicationGatewayBackendAddressPools { - addressPools = append(addressPools, *pool.ID) + if properties.Subnet != nil { + config["subnet_id"] = *properties.Subnet.ID } - } - config["application_gateway_backend_address_pool_ids"] = schema.NewSet(schema.HashString, addressPools) - applicationSecurityGroups := make([]interface{}, 0) - if properties.ApplicationSecurityGroups != nil { - for _, asg := range *properties.ApplicationSecurityGroups { - applicationSecurityGroups = append(applicationSecurityGroups, *asg.ID) + addressPools := make([]interface{}, 0) + if properties.ApplicationGatewayBackendAddressPools != nil { + for _, pool := range *properties.ApplicationGatewayBackendAddressPools { + if v := pool.ID; v != nil { + addressPools = append(addressPools, *v) + } + } + } + config["application_gateway_backend_address_pool_ids"] = schema.NewSet(schema.HashString, addressPools) + + applicationSecurityGroups := make([]interface{}, 0) + if properties.ApplicationSecurityGroups != nil { + for _, asg := range *properties.ApplicationSecurityGroups { + if v := asg.ID; v != nil { + applicationSecurityGroups = append(applicationSecurityGroups, *v) + } + } + } + config["application_security_group_ids"] = schema.NewSet(schema.HashString, applicationSecurityGroups) + + if properties.LoadBalancerBackendAddressPools != nil { + addressPools := make([]interface{}, 0, len(*properties.LoadBalancerBackendAddressPools)) + for _, pool := range *properties.LoadBalancerBackendAddressPools { + if v := pool.ID; v != nil { + addressPools = append(addressPools, *v) + } + } + config["load_balancer_backend_address_pool_ids"] = schema.NewSet(schema.HashString, addressPools) } - } - config["application_security_group_ids"] = schema.NewSet(schema.HashString, applicationSecurityGroups) - if properties.LoadBalancerBackendAddressPools != nil { - addressPools := make([]interface{}, 0, len(*properties.LoadBalancerBackendAddressPools)) - for _, pool := range *properties.LoadBalancerBackendAddressPools { - addressPools = append(addressPools, *pool.ID) + if properties.LoadBalancerInboundNatPools != nil { + inboundNatPools := make([]interface{}, 0, len(*properties.LoadBalancerInboundNatPools)) + for _, rule := range *properties.LoadBalancerInboundNatPools { + if v := rule.ID; v != nil { + inboundNatPools = append(inboundNatPools, *v) + } + } + config["load_balancer_inbound_nat_rules_ids"] = schema.NewSet(schema.HashString, inboundNatPools) } - config["load_balancer_backend_address_pool_ids"] = schema.NewSet(schema.HashString, addressPools) - } - if properties.LoadBalancerInboundNatPools != nil { - inboundNatPools := make([]interface{}, 0, len(*properties.LoadBalancerInboundNatPools)) - for _, rule := range *properties.LoadBalancerInboundNatPools { - inboundNatPools = append(inboundNatPools, *rule.ID) + if properties.Primary != nil { + config["primary"] = *properties.Primary } - config["load_balancer_inbound_nat_rules_ids"] = schema.NewSet(schema.HashString, inboundNatPools) - } - if properties.Primary != nil { - config["primary"] = *properties.Primary - } + if properties.PublicIPAddressConfiguration != nil { + publicIpInfo := properties.PublicIPAddressConfiguration + publicIpConfigs := make([]map[string]interface{}, 0, 1) + publicIpConfig := make(map[string]interface{}) + publicIpConfig["name"] = *publicIpInfo.Name + publicIpConfig["domain_name_label"] = *publicIpInfo.VirtualMachineScaleSetPublicIPAddressConfigurationProperties.DNSSettings + publicIpConfig["idle_timeout"] = *publicIpInfo.VirtualMachineScaleSetPublicIPAddressConfigurationProperties.IdleTimeoutInMinutes + config["public_ip_address_configuration"] = publicIpConfigs + } - if properties.PublicIPAddressConfiguration != nil { - publicIpInfo := properties.PublicIPAddressConfiguration - publicIpConfigs := make([]map[string]interface{}, 0, 1) - publicIpConfig := make(map[string]interface{}) - publicIpConfig["name"] = *publicIpInfo.Name - publicIpConfig["domain_name_label"] = *publicIpInfo.VirtualMachineScaleSetPublicIPAddressConfigurationProperties.DNSSettings - publicIpConfig["idle_timeout"] = *publicIpInfo.VirtualMachineScaleSetPublicIPAddressConfigurationProperties.IdleTimeoutInMinutes - config["public_ip_address_configuration"] = publicIpConfigs + ipConfigs = append(ipConfigs, config) } - - ipConfigs = append(ipConfigs, config) } s["ip_configuration"] = ipConfigs diff --git a/website/docs/r/virtual_machine_scale_set.html.markdown b/website/docs/r/virtual_machine_scale_set.html.markdown index bf25ffaf639c..290f83721b12 100644 --- a/website/docs/r/virtual_machine_scale_set.html.markdown +++ b/website/docs/r/virtual_machine_scale_set.html.markdown @@ -377,9 +377,8 @@ output "principal_id" { * `load_balancer_backend_address_pool_ids` - (Optional) Specifies an array of references to backend address pools of load balancers. A scale set can reference backend address pools of one public and one internal load balancer. Multiple scale sets cannot use the same load balancer. * `load_balancer_inbound_nat_rules_ids` - (Optional) Specifies an array of references to inbound NAT rules for load balancers. * `primary` - (Required) Specifies if this ip_configuration is the primary one. -* `application_security_group_ids` - (Optional) Specifies an array of references to application security groups -* `public_ip_address_configuration` - (Optional) describes a virtual machines scale set IP Configuration's - PublicIPAddress configuration. The public_ip_address_configuration is documented below. +* `application_security_group_ids` - (Optional) Specifies up to `20` application security group IDs. +* `public_ip_address_configuration` - (Optional) Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. The public_ip_address_configuration is documented below. `public_ip_address_configuration` supports the following: From 203d3ff73ed9d8b5c15b2934a74da1443230b6fb Mon Sep 17 00:00:00 2001 From: kt Date: Fri, 26 Oct 2018 12:38:31 -0700 Subject: [PATCH 10/11] fix linting issues --- ...urce_arm_virtual_machine_scale_set_test.go | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index 7d5d6dd4ebd5..cd59d88e7cfb 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -1021,32 +1021,6 @@ func testCheckAzureRMVirtualMachineScaleSetPublicIPName(name, publicIPName strin } } -func testCheckAzureRMVirtualMachineScaleSetApplicationSecurity(name string) resource.TestCheckFunc { - return func(s *terraform.State) error { - resp, err := testGetAzureRMVirtualMachineScaleSet(s, name) - if err != nil { - return err - } - - n := resp.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations - if n == nil || len(*n) == 0 { - return fmt.Errorf("Bad: Could not get network interface configurations for scale set %v", name) - } - - ip := (*n)[0].IPConfigurations - if ip == nil || len(*ip) == 0 { - return fmt.Errorf("Bad: Could not get ip configurations for scale set %v", name) - } - - asgs := (*ip)[0].ApplicationSecurityGroups - if asgs == nil || len(*asgs) == 0 { - return fmt.Errorf("Bad: Application Security Groups was empty for scale set %v", name) - } - - return nil - } -} - func testCheckAzureRMVirtualMachineScaleSetAcceleratedNetworking(name string, boolean bool) resource.TestCheckFunc { return func(s *terraform.State) error { resp, err := testGetAzureRMVirtualMachineScaleSet(s, name) From 17906ce22e79255f804f3bebbbcbe85eccce6183 Mon Sep 17 00:00:00 2001 From: kt Date: Fri, 26 Oct 2018 12:40:08 -0700 Subject: [PATCH 11/11] fix faling test --- azurerm/resource_arm_virtual_machine_scale_set_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index cd59d88e7cfb..fb955e4dda85 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -1452,6 +1452,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" application_security_group_ids = ["${azurerm_application_security_group.test.id}"] }