diff --git a/internal/services/network/application_gateway_data_source.go b/internal/services/network/application_gateway_data_source.go index 3d5c17636aac..cf7c600f7373 100644 --- a/internal/services/network/application_gateway_data_source.go +++ b/internal/services/network/application_gateway_data_source.go @@ -27,6 +27,36 @@ func dataSourceApplicationGateway() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, }, + "backend_address_pool": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "fqdns": { + Type: pluginsdk.TypeSet, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + "ip_addresses": { + Type: pluginsdk.TypeSet, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + "id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, "location": commonschema.LocationComputed(), @@ -57,6 +87,12 @@ func dataSourceApplicationGatewayRead(d *pluginsdk.ResourceData, meta interface{ d.SetId(id.ID()) + if props := resp.ApplicationGatewayPropertiesFormat; props != nil { + if err := d.Set("backend_address_pool", flattenApplicationGatewayBackendAddressPools(props.BackendAddressPools)); err != nil { + return fmt.Errorf("setting `backend_address_pool`: %+v", err) + } + } + d.Set("location", location.NormalizeNilable(resp.Location)) identity, err := flattenApplicationGatewayIdentity(resp.Identity) diff --git a/internal/services/network/application_gateway_data_source_test.go b/internal/services/network/application_gateway_data_source_test.go index 54bd36b994c3..010aa521a4d9 100644 --- a/internal/services/network/application_gateway_data_source_test.go +++ b/internal/services/network/application_gateway_data_source_test.go @@ -38,6 +38,20 @@ func TestAccDataSourceAppGateway_userAssignedIdentity(t *testing.T) { }, }) } +func TestAccDataSourceAppGateway_backendAddressPool(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_application_gateway", "test") + r := AppGatewayDataSource{} + + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: r.backendAddressPool(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key("backend_address_pool.0.id").Exists(), + check.That(data.ResourceName).Key("backend_address_pool.0.name").Exists(), + ), + }, + }) +} func (AppGatewayDataSource) basic(data acceptance.TestData) string { return fmt.Sprintf(` @@ -60,3 +74,13 @@ data "azurerm_application_gateway" "test" { } `, ApplicationGatewayResource{}.UserDefinedIdentity(data)) } +func (AppGatewayDataSource) backendAddressPool(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +data "azurerm_application_gateway" "test" { + resource_group_name = azurerm_application_gateway.test.resource_group_name + name = azurerm_application_gateway.test.name +} +`, ApplicationGatewayResource{}.backendAddressPoolEmptyIpList(data)) +} diff --git a/website/docs/d/application_gateway.html.markdown b/website/docs/d/application_gateway.html.markdown index 753e48c38430..acf442fca7b2 100644 --- a/website/docs/d/application_gateway.html.markdown +++ b/website/docs/d/application_gateway.html.markdown @@ -37,6 +37,8 @@ In addition to the Arguments listed above - the following Attributes are exporte * `id` - The ID of the Application Gateway. +* `backend_address_pool` - A `backend_address_pool` block as defined below. + * `identity` - A `identity` block as defined below. * `location` - The Azure Region where the Application Gateway exists. @@ -45,6 +47,18 @@ In addition to the Arguments listed above - the following Attributes are exporte --- +A `backend_address_pool` block exports the following: + +* `id` - The ID of the Backend Address Pool. + +* `name` - The name of the Backend Address Pool. + +* `fqdns` - A list of FQDN's that are included in the Backend Address Pool. + +* `ip_addresses` - A list of IP Addresses that are included in the Backend Address Pool. + +--- + A `identity` block exports the following: * `identity_ids` - A list of Managed Identity IDs assigned to this Application Gateway.