See below for an example of an application gateway configuration. Tags are used to identify the resources that will be added to the application gateway's backend address pool.
windows_vms={hsw_z1={names=["HSW1TEST","HSW2TEST"]zones=["1"]size="Standard_D2s_v4"virtual_machine_scale_set="testvmss"resource_group="hsw"nics={primary={ip_configuration=[{subnet="main.hsw"}]}}boot_diagnostics={storage_account="diag2"}tags={application="hsw"backend_address_pool="hsw"}}hsw_z2={##Hyperspace Web Servers##names=["HSW3TEST","HSW4TEST"]zones=["2"]size="Standard_D2s_v4"virtual_machine_scale_set="testvmss"resource_group="hsw"nics={primary={ip_configuration=[{subnet="main.hsw"}]}}boot_diagnostics={storage_account="diag2"}tags={application="hsw"backend_address_pool="hsw"}}
Private DNS A Record for a Frontend
A private DNS A record can resolve to an application gateway frontend's private IP by referencing the gateway key (from agws) and the frontend's name. The IP is read at apply time, so Dynamic allocation works. See Private DNS A Record for the full variable reference.
Set the TLS policy enforced on the gateway's HTTPS/TLS listeners with an optional ssl_policy block. The block is a 0-or-1 element list, so omit it (or pass []) to leave the gateway on the Azure default policy. There are two mutually exclusive modes:
Predefined - reference a named Azure policy with policy_name (for example AppGwSslPolicy20220101, which enforces a minimum of TLS 1.2). Keep policy_type = "Predefined" (the default).
Custom - set policy_type = "Custom" (or "CustomV2") and provide min_protocol_version plus the explicit list of cipher_suites.
disabled_protocols is an alternative mode for disabling specific protocol versions; do not combine it with policy_name/policy_type.
Name of a Predefined Azure policy (e.g. AppGwSslPolicy20220101 = min TLS 1.2). Predefined mode only.
null
policy_type
string
Predefined, Custom, or CustomV2.
"Predefined"
disabled_protocols
list(string)
Protocol versions to disable. Alternative to policy_name/policy_type; do not combine.
null
cipher_suites
list(string)
Explicit cipher suite list. Custom mode only.
null
min_protocol_version
string
Minimum TLS protocol version (e.g. TLSv1_2). Custom mode only.
null
Layer 4 (TCP/TLS) Proxy
In addition to the Layer 7 HTTP/HTTPS routing shown above, the gateway supports Layer 4 (TCP/TLS) proxying. The L4 blocks are direct analogues of their L7 counterparts:
listener - the L4 analogue of http_listener.
backend - the L4 analogue of backend_http_settings.
routing_rule - the L4 analogue of request_routing_rule.
Each defaults to [], so existing L7-only gateways are unaffected. A listener and backend use protocol = "Tcp" for a raw TCP passthrough (no TLS termination at the gateway) or protocol = "Tls" to terminate TLS at the gateway. The shared probe block also supports protocol = "Tcp" and protocol = "Tls"; for those L4 protocols the path and match fields do not apply and are omitted by the module, so leave match = null.
Note: L4 support requires azurerm >= 4.67.0, which is the version this repository is pinned at (see src/providers.tf). The Azure Application Gateway L4 (TCP/TLS) feature is in public preview.
The example below adds a TCP passthrough on port 7327 alongside the existing L7 443 listeners (frontend port, L4 listener, backend, routing rule, and a Tcp probe):
agws={dmz={resource_group="dmz"frontend_ip_configuration=[{name="appGwPublicFrontendIp",public_ip_address="appgw"}]frontend_port=[{name="port_443",port=443},{name="port_7327",port=7327}]backend_address_pool=[{name="nginx-pool",target={vm_tag={key="backend_address_pool",value="nginx"}}}]# min TLS 1.2 on the HTTPS/TLS listeners.ssl_policy=[{policy_name="AppGwSslPolicy20220101",policy_type="Predefined"}]# ---- 7327 L4 TCP passthrough (no TLS termination at the gateway) ----listener=[{name="nginx-tcp7327"frontend_ip_configuration_name="appGwPublicFrontendIp"frontend_port_name="port_7327"protocol="Tcp"}]backend=[{name="nginx-tcp7327-backend"protocol="Tcp"port=7327probe_name="nginx-tcp7327-probe"timeout_in_seconds=90}]routing_rule=[{name="nginx-tcp7327-rule"listener_name="nginx-tcp7327"backend_name="nginx-tcp7327-backend"backend_address_pool_name="nginx-pool"priority=130}]# Tcp probe - path/match are invalid for L4 and are omitted by the module.probe=[{name="nginx-tcp7327-probe"protocol="Tcp"port=7327interval=30timeout=20unhealthy_threshold=3pick_host_name_from_backend_http_settings=falsematch=null}]}}
L4 listener Variable Reference
Field
Type
Description
Default
name
string
Listener name.
Required
frontend_ip_configuration_name
string
Name of the frontend_ip_configuration entry this listener binds to.
Required
frontend_port_name
string
Name of the frontend_port entry this listener listens on.
Required
protocol
string
Tcp (raw passthrough, no TLS at the gateway) or Tls (TLS terminated at the gateway).
Required
host_names
list(string)
Host names for SNI routing. Not allowed when protocol = "Tcp".
null
ssl_certificate_name
string
Name of the ssl_certificate entry to present. Required when protocol = "Tls".
null
ssl_profile_name
string
Name of the ssl_profile entry to apply.
null
L4 backend Variable Reference
Field
Type
Description
Default
name
string
Backend settings name.
Required
port
number
Backend port.
Required
protocol
string
Tcp or Tls.
Required
client_ip_preservation_enabled
bool
Preserve the original client IP to the backend.
null
host_name
string
Override host name sent to the backend. Tls only.
null
probe_name
string
Name of the probe entry used for health checks.
null
timeout_in_seconds
number
Backend connection timeout, in seconds.
null
trusted_root_certificate_names
list(string)
Names of trusted_root_certificate entries to trust on the backend.
null
L4 routing_rule Variable Reference
Field
Type
Description
Default
name
string
Routing rule name.
Required
listener_name
string
Name of the L4 listener this rule binds to.
Required
backend_name
string
Name of the L4 backend this rule forwards to.
Required
backend_address_pool_name
string
Name of the backend_address_pool this rule targets.
Required
priority
number
Rule priority.
Required
Note: The probe block is shared between L7 and L4 routing. For protocol = "Tcp" or protocol = "Tls" probes, set match = null; the path and match fields are invalid for L4 probes and are omitted by the module.