diff --git a/azurerm/resource_arm_loadbalancer.go b/azurerm/resource_arm_loadbalancer.go index 9f7aaac1b6ff..5a7037c81b97 100644 --- a/azurerm/resource_arm_loadbalancer.go +++ b/azurerm/resource_arm_loadbalancer.go @@ -92,6 +92,13 @@ func resourceArmLoadBalancer() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "private_ip_addresses": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "tags": tagsSchema(), }, @@ -177,14 +184,20 @@ func resourecArmLoadBalancerRead(d *schema.ResourceData, meta interface{}) error ipconfigs := loadBalancer.LoadBalancerPropertiesFormat.FrontendIPConfigurations d.Set("frontend_ip_configuration", flattenLoadBalancerFrontendIpConfiguration(ipconfigs)) + privateIpAddress := "" + privateIpAddresses := make([]string, 0, len(*ipconfigs)) for _, config := range *ipconfigs { if config.FrontendIPConfigurationPropertiesFormat.PrivateIPAddress != nil { - d.Set("private_ip_address", config.FrontendIPConfigurationPropertiesFormat.PrivateIPAddress) + if privateIpAddress == "" { + privateIpAddress = *config.FrontendIPConfigurationPropertiesFormat.PrivateIPAddress + } - // set the private IP address at most once - break + privateIpAddresses = append(privateIpAddresses, *config.FrontendIPConfigurationPropertiesFormat.PrivateIPAddress) } } + + d.Set("private_ip_address", privateIpAddress) + d.Set("private_ip_addresses", privateIpAddresses) } flattenAndSetTags(d, loadBalancer.Tags) diff --git a/website/docs/r/loadbalancer.html.markdown b/website/docs/r/loadbalancer.html.markdown index e94a8a0ea1d6..c7e4c2c8deef 100644 --- a/website/docs/r/loadbalancer.html.markdown +++ b/website/docs/r/loadbalancer.html.markdown @@ -60,7 +60,8 @@ The following arguments are supported: The following attributes are exported: * `id` - The LoadBalancer ID. -* `private_ip_address` - The private IP address assigned to the load balancer, if any. +* `private_ip_address` - The first private IP address assigned to the load balancer in `frontend_ip_configuration` blocks, if any. +* `private_ip_addresses` - The list of private IP address assigned to the load balancer in `frontend_ip_configuration` blocks, if any. ## Import