-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathagw.tf
132 lines (130 loc) · 4.82 KB
/
agw.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Public Ip
resource "azurerm_public_ip" "main" {
count = (local.app_gateway.enabled && local.app_gateway.public_ip && local.app_gateway.public_ip_id == "") ? 1 : 0
name = local.names.agw
resource_group_name = local.resource_group_name
location = local.location
allocation_method = "Static"
sku = "Standard"
zones = local.zones != [] ? local.zones : null
tags = var.tags
lifecycle {
create_before_destroy = true
}
}
resource "azurerm_application_gateway" "main" {
lifecycle {
# as this ends up managed by aks, we need to ignore changes here
# we only care that it is created and permissions assigned
ignore_changes = [
backend_address_pool,
backend_http_settings,
firewall_policy_id,
frontend_port,
http_listener,
probe,
request_routing_rule,
ssl_certificate,
tags,
waf_configuration,
url_path_map
]
}
count = local.app_gateway.enabled ? 1 : 0
name = local.names.agw
resource_group_name = local.resource_group_name
location = local.location
zones = local.zones != [] ? local.zones : null
sku {
name = local.app_gateway.sku_name
tier = local.app_gateway.sku_tier
capacity = local.app_gateway.sku_capacity
}
gateway_ip_configuration {
name = "appGatewayIpConfig"
subnet_id = local.app_gateway.subnet_id
}
frontend_port {
name = "defaulthttp"
port = 80
}
dynamic "frontend_ip_configuration" {
for_each = local.app_gateway.public_ip ? ["public_ip_configuration"] : []
content {
name = "appGatewayFrontendPublicIP"
public_ip_address_id = local.app_gateway.public_ip_id == "" ? azurerm_public_ip.main[0].id : local.app_gateway.public_ip_id
}
}
dynamic "frontend_ip_configuration" {
for_each = local.app_gateway.private_ip ? ["private_ip_configuration"] : []
content {
name = "appGatewayFrontendPrivateIP"
private_ip_address_allocation = local.private_ip_address_allocation
private_ip_address = local.app_gateway.private_ip_address
subnet_id = coalesce(local.app_gateway.private_ip_subnet_id, local.app_gateway.subnet_id)
}
}
backend_address_pool {
name = "defaultaddresspool"
}
backend_http_settings {
name = "defaulthttpsetting"
cookie_based_affinity = "Disabled"
port = 80
protocol = "Http"
request_timeout = 30
}
dynamic "http_listener" {
for_each = local.app_gateway.public_ip ? ["public_listener"] : []
content {
name = "publiclistener"
frontend_ip_configuration_name = "appGatewayFrontendPublicIP"
frontend_port_name = "defaulthttp"
protocol = "Http"
}
}
dynamic "http_listener" {
for_each = local.app_gateway.private_ip ? ["private_listener"] : []
content {
name = "privatelistener"
frontend_ip_configuration_name = "appGatewayFrontendPrivateIP"
frontend_port_name = "defaulthttp"
protocol = "Http"
}
}
dynamic "request_routing_rule" {
for_each = local.app_gateway.public_ip ? ["public_rr"] : []
content {
name = "public"
rule_type = "Basic"
http_listener_name = "publiclistener"
backend_address_pool_name = "defaultaddresspool"
backend_http_settings_name = "defaulthttpsetting"
priority = local.public_priority != -1 ? local.public_priority : null
}
}
dynamic "request_routing_rule" {
for_each = local.app_gateway.private_ip ? ["private_rr"] : []
content {
name = "private"
rule_type = "Basic"
http_listener_name = "privatelistener"
backend_address_pool_name = "defaultaddresspool"
backend_http_settings_name = "defaulthttpsetting"
priority = local.private_priority != -1 ? local.private_priority : null
}
}
dynamic "waf_configuration" {
for_each = local.is_v2 ? ["waf_configuration"] : []
content {
enabled = local.waf_configuration.enabled
firewall_mode = local.waf_configuration.firewall_mode
rule_set_type = local.waf_configuration.rule_set_type
rule_set_version = local.waf_configuration.rule_set_version
file_upload_limit_mb = local.waf_configuration.file_upload_limit_mb
request_body_check = local.waf_configuration.request_body_check
max_request_body_size_kb = local.waf_configuration.max_request_body_size_kb
}
}
tags = local.tags
}