Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_application_gateway - data source - add backend_address_pool attribute #19026

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions internal/services/network/application_gateway_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ 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.#").HasValue("1"),
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(`
Expand All @@ -60,3 +75,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))
}
14 changes: 14 additions & 0 deletions website/docs/d/application_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down