Expose any dynamically-assigned private IP address

This commit is contained in:
Josh VanderLinden 2017-04-26 05:22:01 +00:00
parent 2636deb8b4
commit d3687fc9e9
2 changed files with 18 additions and 1 deletions

View File

@ -92,6 +92,11 @@ func resourceArmLoadBalancer() *schema.Resource {
},
},
"private_ip_address": {
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchema(),
},
}
@ -172,7 +177,18 @@ func resourecArmLoadBalancerRead(d *schema.ResourceData, meta interface{}) error
d.Set("resource_group_name", id.ResourceGroup)
if loadBalancer.LoadBalancerPropertiesFormat != nil && loadBalancer.LoadBalancerPropertiesFormat.FrontendIPConfigurations != nil {
d.Set("frontend_ip_configuration", flattenLoadBalancerFrontendIpConfiguration(loadBalancer.LoadBalancerPropertiesFormat.FrontendIPConfigurations))
ipconfig := flattenLoadBalancerFrontendIpConfiguration(loadBalancer.LoadBalancerPropertiesFormat.FrontendIPConfigurations)
d.Set("frontend_ip_configuration", ipconfig)
for _, config := range ipconfig {
cfg := config.(map[string]interface{})
if priv_ip, ok := cfg["private_ip_address"]; ok {
d.Set("private_ip_address", priv_ip)
// set the private IP address at most once
break
}
}
}
flattenAndSetTags(d, loadBalancer.Tags)

View File

@ -60,6 +60,7 @@ 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.
## Import