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..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}" } } @@ -1249,6 +1250,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1424,6 +1426,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 +1512,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 +1600,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { } ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1684,6 +1689,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1874,6 +1880,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -1959,6 +1966,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2070,6 +2078,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 +2192,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 +2311,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 +2379,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2434,6 +2446,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2517,6 +2530,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2582,6 +2596,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -2662,6 +2677,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 +2903,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 +2989,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3056,6 +3074,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3151,6 +3170,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3254,6 +3274,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3345,6 +3366,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3456,6 +3478,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3560,6 +3583,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3656,6 +3680,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3742,6 +3767,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 +3863,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -3902,6 +3929,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -4073,6 +4101,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "TestIPConfiguration" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -4149,6 +4178,7 @@ resource "azurerm_virtual_machine_scale_set" "test" { primary = true ip_configuration { name = "primary" + primary = true subnet_id = "${azurerm_subnet.test.id}" } } @@ -4158,6 +4188,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.