@@ -118,7 +118,7 @@ resource "aws_security_group_rule" "ingress_through_https" {
118
118
resource "null_resource" "lb_http_tgs_config" {
119
119
for_each = {
120
120
for name , config in var . http_ports : name => config
121
- if lookup ( config, " type" , " " ) == " " || lookup ( config, " type" , " " ) == " forward"
121
+ if config . type == null || config . type == " forward"
122
122
}
123
123
124
124
triggers = {
@@ -131,7 +131,7 @@ resource "null_resource" "lb_http_tgs_config" {
131
131
resource "random_id" "lb_http_tgs_id" {
132
132
for_each = {
133
133
for name , config in var . http_ports : name => config
134
- if lookup ( config, " type" , " " ) == " " || lookup ( config, " type" , " " ) == " forward"
134
+ if config . type == null || config . type == " forward"
135
135
}
136
136
137
137
byte_length = 2
@@ -147,12 +147,12 @@ resource "random_id" "lb_http_tgs_id" {
147
147
resource "aws_lb_target_group" "lb_http_tgs" {
148
148
for_each = {
149
149
for name , config in var . http_ports : name => config
150
- if lookup ( config, " type" , " " ) == " " || lookup ( config, " type" , " " ) == " forward"
150
+ if config . type == null || config . type == " forward"
151
151
}
152
152
name = " ${ var . name_prefix } -http-${ each . value . target_group_port } -${ random_id . lb_http_tgs_id [each . key ]. hex } "
153
153
port = each. value . target_group_port
154
- protocol = lookup (each. value , " target_group_protocol" , " HTTP" )
155
- protocol_version = lookup (each. value , " target_group_protocol_version" , " HTTP1" )
154
+ protocol = coalesce (each. value . target_group_protocol , " HTTP" )
155
+ protocol_version = coalesce (each. value . target_group_protocol_version , " HTTP1" )
156
156
vpc_id = var. vpc_id
157
157
deregistration_delay = var. deregistration_delay
158
158
slow_start = var. slow_start
@@ -166,15 +166,15 @@ resource "aws_lb_target_group" "lb_http_tgs" {
166
166
}
167
167
}
168
168
health_check {
169
- enabled = lookup (each. value , " target_group_health_check_enabled" , var. target_group_health_check_enabled )
170
- interval = lookup (each. value , " target_group_health_check_interval" , var. target_group_health_check_interval )
171
- path = lookup (each. value , " target_group_health_check_path" , var. target_group_health_check_path )
172
- port = lookup (each. value , " target_group_health_check_port" , var. target_group_health_check_port )
173
- protocol = lookup (each. value , " target_group_health_check_protocol" , var. target_group_health_check_protocol )
174
- timeout = lookup (each. value , " target_group_health_check_timeout" , var. target_group_health_check_timeout )
175
- healthy_threshold = lookup (each. value , " target_group_health_check_healthy_threshold" , var. target_group_health_check_healthy_threshold )
176
- unhealthy_threshold = lookup (each. value , " target_group_health_check_unhealthy_threshold" , var. target_group_health_check_unhealthy_threshold )
177
- matcher = lookup (each. value , " target_group_health_check_matcher" , var. target_group_health_check_matcher )
169
+ enabled = coalesce (each. value . target_group_health_check_enabled , var. target_group_health_check_enabled )
170
+ interval = coalesce (each. value . target_group_health_check_interval , var. target_group_health_check_interval )
171
+ path = coalesce (each. value . target_group_health_check_path , var. target_group_health_check_path )
172
+ port = coalesce (each. value . target_group_health_check_port , var. target_group_health_check_port )
173
+ protocol = coalesce (each. value . target_group_health_check_protocol , var. target_group_health_check_protocol )
174
+ timeout = coalesce (each. value . target_group_health_check_timeout , var. target_group_health_check_timeout )
175
+ healthy_threshold = coalesce (each. value . target_group_health_check_healthy_threshold , var. target_group_health_check_healthy_threshold )
176
+ unhealthy_threshold = coalesce (each. value . target_group_health_check_unhealthy_threshold , var. target_group_health_check_unhealthy_threshold )
177
+ matcher = coalesce (each. value . target_group_health_check_matcher , var. target_group_health_check_matcher )
178
178
}
179
179
target_type = " ip"
180
180
tags = merge (
@@ -194,7 +194,7 @@ resource "aws_lb_target_group" "lb_http_tgs" {
194
194
resource "null_resource" "lb_https_tgs_config" {
195
195
for_each = {
196
196
for name , config in var . https_ports : name => config
197
- if lookup ( config, " type" , " " ) == " " || lookup ( config, " type" , " " ) == " forward"
197
+ if config . type == null || config . type == " forward"
198
198
}
199
199
200
200
triggers = {
@@ -207,7 +207,7 @@ resource "null_resource" "lb_https_tgs_config" {
207
207
resource "random_id" "lb_https_tgs_id" {
208
208
for_each = {
209
209
for name , config in var . https_ports : name => config
210
- if lookup ( config, " type" , " " ) == " " || lookup ( config, " type" , " " ) == " forward"
210
+ if config . type == null || config . type == " forward"
211
211
}
212
212
213
213
byte_length = 2
@@ -223,12 +223,12 @@ resource "random_id" "lb_https_tgs_id" {
223
223
resource "aws_lb_target_group" "lb_https_tgs" {
224
224
for_each = {
225
225
for name , config in var . https_ports : name => config
226
- if lookup ( config, " type" , " " ) == " " || lookup ( config, " type" , " " ) == " forward"
226
+ if config . type == null || config . type == " forward"
227
227
}
228
228
name = " ${ var . name_prefix } -https-${ each . value . target_group_port } -${ random_id . lb_https_tgs_id [each . key ]. hex } "
229
229
port = each. value . target_group_port
230
- protocol = lookup (each. value , " target_group_protocol" , " HTTP" )
231
- protocol_version = lookup (each. value , " target_group_protocol_version" , " HTTP1" )
230
+ protocol = coalesce (each. value . target_group_protocol , " HTTP" )
231
+ protocol_version = coalesce (each. value . target_group_protocol_version , " HTTP1" )
232
232
vpc_id = var. vpc_id
233
233
deregistration_delay = var. deregistration_delay
234
234
slow_start = var. slow_start
@@ -242,15 +242,15 @@ resource "aws_lb_target_group" "lb_https_tgs" {
242
242
}
243
243
}
244
244
health_check {
245
- enabled = lookup (each. value , " target_group_health_check_enabled" , var. target_group_health_check_enabled )
246
- interval = lookup (each. value , " target_group_health_check_interval" , var. target_group_health_check_interval )
247
- path = lookup (each. value , " target_group_health_check_path" , var. target_group_health_check_path )
248
- port = lookup (each. value , " target_group_health_check_port" , var. target_group_health_check_port )
249
- protocol = lookup (each. value , " target_group_health_check_protocol" , var. target_group_health_check_protocol )
250
- timeout = lookup (each. value , " target_group_health_check_timeout" , var. target_group_health_check_timeout )
251
- healthy_threshold = lookup (each. value , " target_group_health_check_healthy_threshold" , var. target_group_health_check_healthy_threshold )
252
- unhealthy_threshold = lookup (each. value , " target_group_health_check_unhealthy_threshold" , var. target_group_health_check_unhealthy_threshold )
253
- matcher = lookup (each. value , " target_group_health_check_matcher" , var. target_group_health_check_matcher )
245
+ enabled = coalesce (each. value . target_group_health_check_enabled , var. target_group_health_check_enabled )
246
+ interval = coalesce (each. value . target_group_health_check_interval , var. target_group_health_check_interval )
247
+ path = coalesce (each. value . target_group_health_check_path , var. target_group_health_check_path )
248
+ port = coalesce (each. value . target_group_health_check_port , var. target_group_health_check_port )
249
+ protocol = coalesce (each. value . target_group_health_check_protocol , var. target_group_health_check_protocol )
250
+ timeout = coalesce (each. value . target_group_health_check_timeout , var. target_group_health_check_timeout )
251
+ healthy_threshold = coalesce (each. value . target_group_health_check_healthy_threshold , var. target_group_health_check_healthy_threshold )
252
+ unhealthy_threshold = coalesce (each. value . target_group_health_check_unhealthy_threshold , var. target_group_health_check_unhealthy_threshold )
253
+ matcher = coalesce (each. value . target_group_health_check_matcher , var. target_group_health_check_matcher )
254
254
}
255
255
target_type = " ip"
256
256
tags = merge (
@@ -277,7 +277,7 @@ resource "aws_lb_listener" "lb_http_listeners" {
277
277
protocol = " HTTP"
278
278
279
279
dynamic "default_action" {
280
- for_each = lookup ( each. value , " type" , " " ) == " redirect" ? [1 ] : []
280
+ for_each = each. value . type == " redirect" ? [1 ] : []
281
281
content {
282
282
type = " redirect"
283
283
@@ -287,27 +287,27 @@ resource "aws_lb_listener" "lb_http_listeners" {
287
287
port = each. value . port
288
288
protocol = each. value . protocol
289
289
query = each. value . query
290
- status_code = lookup (each. value , " status_code" , " HTTP_301" )
290
+ status_code = coalesce (each. value . status_code , " HTTP_301" )
291
291
}
292
292
}
293
293
}
294
294
295
295
dynamic "default_action" {
296
- for_each = lookup ( each. value , " type" , " " ) == " fixed-response" ? [1 ] : []
296
+ for_each = each. value . type == " fixed-response" ? [1 ] : []
297
297
content {
298
298
type = " fixed-response"
299
299
300
300
fixed_response {
301
301
content_type = each. value . content_type
302
302
message_body = each. value . message_body
303
- status_code = lookup (each. value , " status_code" , " 200" )
303
+ status_code = coalesce (each. value . status_code , " 200" )
304
304
}
305
305
}
306
306
}
307
307
308
308
# We fallback to using forward type action if type is not defined
309
309
dynamic "default_action" {
310
- for_each = (lookup ( each. value , " type" , " " ) == " " || lookup ( each. value , " type" , " " ) == " forward" ) ? [1 ] : []
310
+ for_each = (each. value . type == null || each. value . type == " forward" ) ? [1 ] : []
311
311
content {
312
312
target_group_arn = aws_lb_target_group. lb_http_tgs [each . key ]. arn
313
313
type = " forward"
@@ -332,7 +332,7 @@ resource "aws_lb_listener" "lb_https_listeners" {
332
332
certificate_arn = var. default_certificate_arn
333
333
334
334
dynamic "default_action" {
335
- for_each = lookup ( each. value , " type" , " " ) == " redirect" ? [1 ] : []
335
+ for_each = each. value . type == " redirect" ? [1 ] : []
336
336
content {
337
337
type = " redirect"
338
338
@@ -342,27 +342,27 @@ resource "aws_lb_listener" "lb_https_listeners" {
342
342
port = each. value . port
343
343
protocol = each. value . protocol
344
344
query = each. value . query
345
- status_code = lookup (each. value , " status_code" , " HTTP_301" )
345
+ status_code = coalesce (each. value . status_code , " HTTP_301" )
346
346
}
347
347
}
348
348
}
349
349
350
350
dynamic "default_action" {
351
- for_each = lookup ( each. value , " type" , " " ) == " fixed-response" ? [1 ] : []
351
+ for_each = each. value . type == " fixed-response" ? [1 ] : []
352
352
content {
353
353
type = " fixed-response"
354
354
355
355
fixed_response {
356
356
content_type = each. value . content_type
357
357
message_body = each. value . message_body
358
- status_code = lookup (each. value , " status_code" , " 200" )
358
+ status_code = coalesce (each. value . status_code , " 200" )
359
359
}
360
360
}
361
361
}
362
362
363
363
# We fallback to using forward type action if type is not defined
364
364
dynamic "default_action" {
365
- for_each = (lookup ( each. value , " type" , " " ) == " " || lookup ( each. value , " type" , " " ) == " forward" ) ? [1 ] : []
365
+ for_each = (each. value . type == null || each. value . type == " forward" ) ? [1 ] : []
366
366
content {
367
367
target_group_arn = aws_lb_target_group. lb_https_tgs [each . key ]. arn
368
368
type = " forward"
0 commit comments