From d11ca34c05ac4f76bf2e0920d8f920fa1f1e4871 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Mon, 8 Oct 2018 13:46:54 +0100 Subject: [PATCH 1/2] network_profile.*.ip_configuration.*.primary now required for azure_virtual_machine_scale_set --- .../resource_arm_virtual_machine_scale_set.go | 10 +++---- ...urce_arm_virtual_machine_scale_set_test.go | 29 +++++++++++++++++++ .../r/virtual_machine_scale_set.html.markdown | 4 ++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/azurerm/resource_arm_virtual_machine_scale_set.go b/azurerm/resource_arm_virtual_machine_scale_set.go index 005d0691eede..ef42ea143ac7 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set.go +++ b/azurerm/resource_arm_virtual_machine_scale_set.go @@ -396,7 +396,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { "primary": { Type: schema.TypeBool, - Optional: true, + Required: true, }, "public_ip_address_configuration": { @@ -1480,6 +1480,7 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) * for _, ipConfigConfig := range ipConfigurationConfigs { ipconfig := ipConfigConfig.(map[string]interface{}) name := ipconfig["name"].(string) + primary := ipconfig["primary"].(bool) subnetId := ipconfig["subnet_id"].(string) ipConfiguration := compute.VirtualMachineScaleSetIPConfiguration{ @@ -1491,6 +1492,8 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) * }, } + ipConfiguration.Primary = &primary + if v := ipconfig["application_gateway_backend_address_pool_ids"]; v != nil { pools := v.(*schema.Set).List() resources := make([]compute.SubResource, 0, len(pools)) @@ -1527,11 +1530,6 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) * ipConfiguration.LoadBalancerInboundNatPools = &rulesResources } - if v := ipconfig["primary"]; v != nil { - primary := v.(bool) - ipConfiguration.Primary = &primary - } - if v := ipconfig["public_ip_address_configuration"]; v != nil { publicIpConfigs := v.([]interface{}) for _, publicIpConfigConfig := range publicIpConfigs { diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index 624279c753e9..df31c4fce2b4 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -1249,6 +1249,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1424,6 +1425,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { accelerated_networking = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1509,6 +1511,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_forwarding = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1596,6 +1599,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1684,6 +1688,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1874,6 +1879,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2070,6 +2076,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"] } @@ -2183,6 +2190,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"] } @@ -2301,6 +2309,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"] } @@ -2368,6 +2377,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2434,6 +2444,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2517,6 +2528,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2582,6 +2594,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2662,6 +2675,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" application_gateway_backend_address_pool_ids = ["${azurerm_application_gateway.test.backend_address_pool.0.id}"] } @@ -2887,6 +2901,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"] load_balancer_inbound_nat_rules_ids = ["${azurerm_lb_nat_pool.test.id}"] @@ -2972,6 +2987,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3056,6 +3072,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3151,6 +3168,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3254,6 +3272,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3345,6 +3364,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3456,6 +3476,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3560,6 +3581,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3656,6 +3678,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3742,6 +3765,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.test.id}"] } @@ -3837,6 +3861,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3902,6 +3927,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -4073,6 +4099,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -4149,6 +4176,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "primary" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -4158,6 +4186,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = false ip_configuration { name = "secondary" + primary = true subnet_id = "${azurerm_subnet.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 02c189f56d2e..cda01debc21a 100644 --- a/website/docs/r/virtual_machine_scale_set.html.markdown +++ b/website/docs/r/virtual_machine_scale_set.html.markdown @@ -130,6 +130,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.bpepool.id}"] load_balancer_inbound_nat_rules_ids = ["${element(azurerm_lb_nat_pool.lbnatpool.*.id, count.index)}"] @@ -216,6 +217,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -374,7 +376,7 @@ output "principal_id" { * `application_gateway_backend_address_pool_ids` - (Optional) Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of one application gateway. Multiple scale sets cannot use the same application gateway. * `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. +* `primary` - (Required) Specifies if this ip_configuration is the primary one. * `public_ip_address_configuration` - (Optional) describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. The public_ip_address_configuration is documented below. From 7e40b6b87338b2de1ab1391fd449f3e7440d1a96 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 10 Oct 2018 12:46:21 +1100 Subject: [PATCH 2/2] Adding a couple of missing `primary = true` assignments --- azurerm/resource_arm_virtual_machine_scale_set_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azurerm/resource_arm_virtual_machine_scale_set_test.go b/azurerm/resource_arm_virtual_machine_scale_set_test.go index df31c4fce2b4..f0fe0ef05d3d 100644 --- a/azurerm/resource_arm_virtual_machine_scale_set_test.go +++ b/azurerm/resource_arm_virtual_machine_scale_set_test.go @@ -1164,6 +1164,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1965,6 +1966,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } }