-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmain.tf
163 lines (135 loc) · 5.51 KB
/
main.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
resource "azurerm_application_gateway" "main" {
name = var.name
resource_group_name = var.resource_group_name
location = var.location
tags = var.tags
zones = var.zones
enable_http2 = var.enable_http2
firewall_policy_id = var.firewall_policy_id
sku {
name = var.sku_name
tier = var.sku_name
capacity = var.capacity
}
dynamic "autoscale_configuration" {
for_each = var.autoscale_configuration != null ? [""] : []
content {
min_capacity = var.autoscale_configuration.min_capacity
max_capacity = var.autoscale_configuration.max_capacity
}
}
dynamic "identity" {
for_each = var.identity_id != null ? [""] : []
content {
type = "UserAssigned"
identity_ids = [var.identity_id]
}
}
gateway_ip_configuration {
name = "GatewayIpConfiguration"
subnet_id = var.subnet_id
}
frontend_ip_configuration {
name = "FrontendPublicIpConfiguration"
public_ip_address_id = var.frontend_ip_configuration.public_ip_address_id
}
dynamic "frontend_ip_configuration" {
for_each = var.frontend_ip_configuration.subnet_id != null ? [""] : []
content {
name = "FrontendPrivateIpConfiguration"
subnet_id = var.subnet_id
private_ip_address_allocation = var.subnet_id != null ? "Static" : null
private_ip_address = var.frontend_ip_configuration.private_ip_address
}
}
dynamic "backend_address_pool" {
for_each = var.backend_address_pools
content {
name = backend_address_pool.value.name
fqdns = backend_address_pool.value.fqdns
ip_addresses = backend_address_pool.value.ip_addresses
}
}
dynamic "frontend_port" {
for_each = [for port in distinct(var.http_listeners[*].port) : port]
content {
name = tostring(frontend_port.value)
port = frontend_port.value
}
}
ssl_policy {
policy_type = var.default_ssl_policy.policy_type
policy_name = var.default_ssl_policy.policy_name
min_protocol_version = var.default_ssl_policy.min_protocol_version
cipher_suites = var.default_ssl_policy.cipher_suites
}
dynamic "ssl_profile" {
for_each = var.ssl_profiles
content {
name = ssl_profile.value.name
ssl_policy {
policy_type = ssl_profile.value.policy_type
policy_name = ssl_profile.value.policy_name
min_protocol_version = ssl_profile.value.min_protocol_version
cipher_suites = ssl_profile.value.cipher_suites
}
}
}
dynamic "ssl_certificate" {
for_each = nonsensitive(var.ssl_certificates)
content {
name = ssl_certificate.value.name
data = ssl_certificate.value.data
password = ssl_certificate.value.password
key_vault_secret_id = ssl_certificate.value.key_vault_secret_id
}
}
dynamic "http_listener" {
for_each = var.http_listeners
content {
name = http_listener.value.name
frontend_ip_configuration_name = http_listener.value.frontend_ip_configuration == "Private" ? "FrontendPrivateIpConfiguration" : "FrontendPublicIpConfiguration"
frontend_port_name = http_listener.value.port
protocol = http_listener.value.protocol
host_name = http_listener.value.host_name
ssl_certificate_name = http_listener.value.ssl_certificate_name
}
}
dynamic "probe" {
for_each = var.probes
content {
name = probe.value.name
host = probe.value.host
protocol = probe.value.protocol
path = probe.value.path
interval = probe.value.interval
timeout = probe.value.timeout
unhealthy_threshold = probe.value.unhealthy_threshold
pick_host_name_from_backend_http_settings = probe.value.host == null ? true : null
}
}
dynamic "backend_http_settings" {
for_each = var.backend_http_settings
content {
name = backend_http_settings.value.name
port = backend_http_settings.value.port
protocol = backend_http_settings.value.protocol
cookie_based_affinity = backend_http_settings.value.cookie_based_affinity
request_timeout = backend_http_settings.value.request_timeout
host_name = backend_http_settings.value.host_name
pick_host_name_from_backend_address = backend_http_settings.value.host_name == null ? true : null
probe_name = backend_http_settings.value.probe_name
}
}
dynamic "request_routing_rule" {
for_each = var.request_routing_rules
content {
name = request_routing_rule.value.name
rule_type = "Basic"
priority = request_routing_rule.value.priority
http_listener_name = request_routing_rule.value.http_listener_name
backend_address_pool_name = request_routing_rule.value.backend_address_pool_name
backend_http_settings_name = request_routing_rule.value.backend_http_settings_name
}
}
}