diff --git a/azurerm/data_source_loadbalancer_backend_address_pool.go b/azurerm/data_source_loadbalancer_backend_address_pool.go index bc4ab6382f8a..ec695049b6f1 100644 --- a/azurerm/data_source_loadbalancer_backend_address_pool.go +++ b/azurerm/data_source_loadbalancer_backend_address_pool.go @@ -29,6 +29,19 @@ func dataSourceArmLoadBalancerBackendAddressPool() *schema.Resource { Required: true, ValidateFunc: azure.ValidateResourceID, }, + + "backend_ip_configurations": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, }, } } @@ -45,12 +58,27 @@ func dataSourceArmLoadBalancerBackendAddressPoolRead(d *schema.ResourceData, met return fmt.Errorf("Unable to retrieve Backend Address Pool %q since Load Balancer %q was not found", name, loadBalancerId) } - config, _, exists := findLoadBalancerBackEndAddressPoolByName(loadBalancer, name) + bap, _, exists := findLoadBalancerBackEndAddressPoolByName(loadBalancer, name) if !exists { return fmt.Errorf("Backend Address Pool %q was not found in Load Balancer %q", name, loadBalancerId) } - d.SetId(*config.ID) + d.SetId(*bap.ID) + + backendIPConfigurations := make([]interface{}, 0) + if props := bap.BackendAddressPoolPropertiesFormat; props != nil { + if beipConfigs := props.BackendIPConfigurations; beipConfigs != nil { + for _, config := range *beipConfigs { + ipConfig := make(map[string]interface{}) + if id := config.ID; id != nil { + ipConfig["id"] = *id + backendIPConfigurations = append(backendIPConfigurations, ipConfig) + } + } + } + } + + d.Set("backend_ip_configurations", backendIPConfigurations) return nil } diff --git a/website/docs/d/loadbalancer_backend_address_pool.html.markdown b/website/docs/d/loadbalancer_backend_address_pool.html.markdown index 8347ad0aa22a..b3458b7cec80 100644 --- a/website/docs/d/loadbalancer_backend_address_pool.html.markdown +++ b/website/docs/d/loadbalancer_backend_address_pool.html.markdown @@ -9,7 +9,7 @@ description: |- # Data Source: azurerm_lb_backend_address_pool -Use this data source to access information about an existing Load Balancer Backend Address Pool. +Use this data source to access information about an existing Load Balancer's Backend Address Pool. ## Example Usage @@ -21,11 +21,15 @@ data "azurerm_lb" "test" { data "azurerm_lb_backend_address_pool" "test" { name = "first" - loadbalancer_id = "${data.azurerm_lb.test.id}" + loadbalancer_id = data.azurerm_lb.test.id } output "backend_address_pool_id" { - value = "${data.azurerm_lb_backend_address_pool.test.id}" + value = data.azurerm_lb_backend_address_pool.test.id +} + +output "backend_ip_configuration_ids" { + value = data.azurerm_lb_backend_address_pool.beap.backend_ip_configurations.*.id } ``` @@ -40,3 +44,7 @@ output "backend_address_pool_id" { The following attributes are exported: * `id` - The ID of the Backend Address Pool. + +* `name` - The name of the Backend Address Pool. + +* `backend_ip_configurations` - An array of references to IP addresses defined in network interfaces.