Skip to content

Commit 739fa45

Browse files
Merge pull request #8210 from simonbrady/fix-8209-app-gateway-empty-backend
Allow empty ip_addresses list for azurerm_application_gateway (#8209)
2 parents b3c7f7f + d844f8b commit 739fa45

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

azurerm/internal/services/network/application_gateway_resource.go

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ func resourceArmApplicationGateway() *schema.Resource {
123123
"ip_addresses": {
124124
Type: schema.TypeList,
125125
Optional: true,
126-
MinItems: 1,
127126
Elem: &schema.Schema{
128127
Type: schema.TypeString,
129128
ValidateFunc: validate.IPv4Address,

azurerm/internal/services/network/tests/application_gateway_resource_test.go

+91
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,25 @@ func TestAccAzureRMApplicationGateway_IncludePathWithTargetURL(t *testing.T) {
10341034
})
10351035
}
10361036

1037+
func TestAccAzureRMApplicationGateway_backendAddressPoolEmptyIpList(t *testing.T) {
1038+
data := acceptance.BuildTestData(t, "azurerm_application_gateway", "test")
1039+
1040+
resource.ParallelTest(t, resource.TestCase{
1041+
PreCheck: func() { acceptance.PreCheck(t) },
1042+
Providers: acceptance.SupportedProviders,
1043+
CheckDestroy: testCheckAzureRMApplicationGatewayDestroy,
1044+
Steps: []resource.TestStep{
1045+
{
1046+
Config: testAccAzureRMApplicationGateway_backendAddressPoolEmptyIpList(data),
1047+
Check: resource.ComposeTestCheckFunc(
1048+
testCheckAzureRMApplicationGatewayExists(data.ResourceName),
1049+
),
1050+
},
1051+
data.ImportStep(),
1052+
},
1053+
})
1054+
}
1055+
10371056
func testCheckAzureRMApplicationGatewayExists(resourceName string) resource.TestCheckFunc {
10381057
return func(s *terraform.State) error {
10391058
client := acceptance.AzureProvider.Meta().(*clients.Client).Network.ApplicationGatewaysClient
@@ -5478,3 +5497,75 @@ resource "azurerm_application_gateway" "test" {
54785497
}
54795498
`, template, data.RandomInteger)
54805499
}
5500+
5501+
func testAccAzureRMApplicationGateway_backendAddressPoolEmptyIpList(data acceptance.TestData) string {
5502+
template := testAccAzureRMApplicationGateway_template(data)
5503+
return fmt.Sprintf(`
5504+
%s
5505+
5506+
# since these variables are re-used - a locals block makes this more maintainable
5507+
locals {
5508+
backend_address_pool_name = "${azurerm_virtual_network.test.name}-beap"
5509+
frontend_port_name = "${azurerm_virtual_network.test.name}-feport"
5510+
frontend_ip_configuration_name = "${azurerm_virtual_network.test.name}-feip"
5511+
http_setting_name = "${azurerm_virtual_network.test.name}-be-htst"
5512+
listener_name = "${azurerm_virtual_network.test.name}-httplstn"
5513+
request_routing_rule_name = "${azurerm_virtual_network.test.name}-rqrt"
5514+
}
5515+
5516+
resource "azurerm_application_gateway" "test" {
5517+
name = "acctestag-%d"
5518+
resource_group_name = azurerm_resource_group.test.name
5519+
location = azurerm_resource_group.test.location
5520+
5521+
sku {
5522+
name = "Standard_Small"
5523+
tier = "Standard"
5524+
capacity = 2
5525+
}
5526+
5527+
gateway_ip_configuration {
5528+
name = "my-gateway-ip-configuration"
5529+
subnet_id = azurerm_subnet.test.id
5530+
}
5531+
5532+
frontend_port {
5533+
name = local.frontend_port_name
5534+
port = 80
5535+
}
5536+
5537+
frontend_ip_configuration {
5538+
name = local.frontend_ip_configuration_name
5539+
public_ip_address_id = azurerm_public_ip.test.id
5540+
}
5541+
5542+
backend_address_pool {
5543+
name = local.backend_address_pool_name
5544+
ip_addresses = []
5545+
}
5546+
5547+
backend_http_settings {
5548+
name = local.http_setting_name
5549+
cookie_based_affinity = "Disabled"
5550+
port = 80
5551+
protocol = "Http"
5552+
request_timeout = 1
5553+
}
5554+
5555+
http_listener {
5556+
name = local.listener_name
5557+
frontend_ip_configuration_name = local.frontend_ip_configuration_name
5558+
frontend_port_name = local.frontend_port_name
5559+
protocol = "Http"
5560+
}
5561+
5562+
request_routing_rule {
5563+
name = local.request_routing_rule_name
5564+
rule_type = "Basic"
5565+
http_listener_name = local.listener_name
5566+
backend_address_pool_name = local.backend_address_pool_name
5567+
backend_http_settings_name = local.http_setting_name
5568+
}
5569+
}
5570+
`, template, data.RandomInteger)
5571+
}

0 commit comments

Comments
 (0)