Skip to content

Commit

Permalink
Merge pull request #633 from tevert/master
Browse files Browse the repository at this point in the history
Fixes #628 - multiple output IPs for azurerm_lb
  • Loading branch information
tombuildsstuff authored Dec 18, 2017
2 parents fdb36da + efc9e35 commit 867f40a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 16 additions & 3 deletions azurerm/resource_arm_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/loadbalancer.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 867f40a

Please sign in to comment.