Skip to content

Commit

Permalink
Merge pull request #8210 from simonbrady/fix-8209-app-gateway-empty-b…
Browse files Browse the repository at this point in the history
…ackend

Allow empty ip_addresses list for azurerm_application_gateway (#8209)
  • Loading branch information
tombuildsstuff authored Aug 24, 2020
2 parents b3c7f7f + d844f8b commit 739fa45
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func resourceArmApplicationGateway() *schema.Resource {
"ip_addresses": {
Type: schema.TypeList,
Optional: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validate.IPv4Address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,25 @@ func TestAccAzureRMApplicationGateway_IncludePathWithTargetURL(t *testing.T) {
})
}

func TestAccAzureRMApplicationGateway_backendAddressPoolEmptyIpList(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_application_gateway", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMApplicationGatewayDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMApplicationGateway_backendAddressPoolEmptyIpList(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationGatewayExists(data.ResourceName),
),
},
data.ImportStep(),
},
})
}

func testCheckAzureRMApplicationGatewayExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := acceptance.AzureProvider.Meta().(*clients.Client).Network.ApplicationGatewaysClient
Expand Down Expand Up @@ -5478,3 +5497,75 @@ resource "azurerm_application_gateway" "test" {
}
`, template, data.RandomInteger)
}

func testAccAzureRMApplicationGateway_backendAddressPoolEmptyIpList(data acceptance.TestData) string {
template := testAccAzureRMApplicationGateway_template(data)
return fmt.Sprintf(`
%s
# since these variables are re-used - a locals block makes this more maintainable
locals {
backend_address_pool_name = "${azurerm_virtual_network.test.name}-beap"
frontend_port_name = "${azurerm_virtual_network.test.name}-feport"
frontend_ip_configuration_name = "${azurerm_virtual_network.test.name}-feip"
http_setting_name = "${azurerm_virtual_network.test.name}-be-htst"
listener_name = "${azurerm_virtual_network.test.name}-httplstn"
request_routing_rule_name = "${azurerm_virtual_network.test.name}-rqrt"
}
resource "azurerm_application_gateway" "test" {
name = "acctestag-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku {
name = "Standard_Small"
tier = "Standard"
capacity = 2
}
gateway_ip_configuration {
name = "my-gateway-ip-configuration"
subnet_id = azurerm_subnet.test.id
}
frontend_port {
name = local.frontend_port_name
port = 80
}
frontend_ip_configuration {
name = local.frontend_ip_configuration_name
public_ip_address_id = azurerm_public_ip.test.id
}
backend_address_pool {
name = local.backend_address_pool_name
ip_addresses = []
}
backend_http_settings {
name = local.http_setting_name
cookie_based_affinity = "Disabled"
port = 80
protocol = "Http"
request_timeout = 1
}
http_listener {
name = local.listener_name
frontend_ip_configuration_name = local.frontend_ip_configuration_name
frontend_port_name = local.frontend_port_name
protocol = "Http"
}
request_routing_rule {
name = local.request_routing_rule_name
rule_type = "Basic"
http_listener_name = local.listener_name
backend_address_pool_name = local.backend_address_pool_name
backend_http_settings_name = local.http_setting_name
}
}
`, template, data.RandomInteger)
}

0 comments on commit 739fa45

Please sign in to comment.