Skip to content

Commit

Permalink
Merge pull request #3144 from Lucretius/AGW_zones
Browse files Browse the repository at this point in the history
`azurerm_application_gateway` - support for `zones`
  • Loading branch information
tombuildsstuff committed Mar 29, 2019
2 parents 15e187d + 314621b commit 256c2b9
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
5 changes: 5 additions & 0 deletions azurerm/resource_arm_application_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func resourceArmApplicationGateway() *schema.Resource {

"location": locationSchema(),

"zones": zonesSchema(),

"resource_group_name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -999,9 +1001,11 @@ func resourceArmApplicationGatewayCreateUpdate(d *schema.ResourceData, meta inte
sslPolicy := expandApplicationGatewaySslPolicy(d)
customErrorConfigurations := expandApplicationGatewayCustomErrorConfigurations(d.Get("custom_error_configuration").([]interface{}))
urlPathMaps := expandApplicationGatewayURLPathMaps(d, gatewayID)
zones := expandZones(d.Get("zones").([]interface{}))

gateway := network.ApplicationGateway{
Location: utils.String(location),
Zones: zones,

Tags: expandTags(tags),
ApplicationGatewayPropertiesFormat: &network.ApplicationGatewayPropertiesFormat{
Expand Down Expand Up @@ -1103,6 +1107,7 @@ func resourceArmApplicationGatewayRead(d *schema.ResourceData, meta interface{})
if location := applicationGateway.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
d.Set("zones", applicationGateway.Zones)

if props := applicationGateway.ApplicationGatewayPropertiesFormat; props != nil {
flattenedCerts := flattenApplicationGatewayAuthenticationCertificates(props.AuthenticationCertificates, d)
Expand Down
109 changes: 109 additions & 0 deletions azurerm/resource_arm_application_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,35 @@ func TestAccAzureRMApplicationGateway_basic(t *testing.T) {
})
}

func TestAccAzureRMApplicationGateway_zones(t *testing.T) {
resourceName := "azurerm_application_gateway.test"
ri := tf.AccRandTimeInt()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMApplicationGatewayDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMApplicationGateway_zones(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationGatewayExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "Standard_v2"),
resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "Standard_v2"),
resource.TestCheckResourceAttr(resourceName, "zones.#", "2"),
resource.TestCheckResourceAttr(resourceName, "sku.0.capacity", "2"),
resource.TestCheckResourceAttr(resourceName, "waf_configuration.#", "0"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMApplicationGateway_overridePath(t *testing.T) {
resourceName := "azurerm_application_gateway.test"
ri := tf.AccRandTimeInt()
Expand Down Expand Up @@ -635,6 +664,86 @@ resource "azurerm_application_gateway" "test" {
`, template, rInt)
}

func testAccAzureRMApplicationGateway_zones(rInt int, location string) string {
template := testAccAzureRMApplicationGateway_template(rInt, location)
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_public_ip" "test_standard" {
name = "acctest-pubip-%d-standard"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Standard"
allocation_method = "Static"
}
resource "azurerm_application_gateway" "test" {
name = "acctestag-%d"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
zones = ["1", "2"]
sku {
name = "Standard_v2"
tier = "Standard_v2"
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_standard.id}"
}
backend_address_pool {
name = "${local.backend_address_pool_name}"
}
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, rInt, rInt)
}

func testAccAzureRMApplicationGateway_overridePath(rInt int, location string) string {
template := testAccAzureRMApplicationGateway_template(rInt, location)
return fmt.Sprintf(`
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/application_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ The following arguments are supported:

* `sku` - (Required) A `sku` block as defined below.

* `zones` - (Optional) A collection of availability zones to spread the Application Gateway over.

-> **Please Note**: Availability Zones are [only supported in several regions at this time](https://docs.microsoft.com/en-us/azure/availability-zones/az-overview). They are also only supported for [v2 SKUs](https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-autoscaling-zone-redundant)

---

* `authentication_certificate` - (Optional) One or more `authentication_certificate` blocks as defined below.
Expand Down

0 comments on commit 256c2b9

Please sign in to comment.