Skip to content

Commit

Permalink
azurerm_application_gateway - data source - add backend_address_poo…
Browse files Browse the repository at this point in the history
…l attribute (#19026)

Co-authored-by: Thomas Orrick <thomas.orrick@q2ebanking.com>
  • Loading branch information
torrick and Thomas Orrick authored Oct 31, 2022
1 parent ffa0928 commit 42fdfb2
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
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
24 changes: 24 additions & 0 deletions internal/services/network/application_gateway_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand All @@ -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))
}
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

0 comments on commit 42fdfb2

Please sign in to comment.