Skip to content

Commit 8132110

Browse files
authored
feat: Allow multiple listener rule condition blocks (#359)
1 parent 10e6637 commit 8132110

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

examples/complete-alb/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ module "alb" {
248248
query_string = {
249249
key = "weighted"
250250
value = "true"
251+
},
252+
path_pattern = {
253+
values = ["/some/path"]
251254
}
252255
}]
253256
}

main.tf

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ resource "aws_lb_listener_rule" "this" {
360360
}
361361

362362
dynamic "condition" {
363-
for_each = try(each.value.conditions, [])
363+
for_each = [for condition in each.value.conditions : condition if contains(keys(condition), "host_header")]
364364

365365
content {
366366
dynamic "host_header" {
@@ -370,7 +370,13 @@ resource "aws_lb_listener_rule" "this" {
370370
values = host_header.value.values
371371
}
372372
}
373+
}
374+
}
375+
376+
dynamic "condition" {
377+
for_each = [for condition in each.value.conditions : condition if contains(keys(condition), "http_header")]
373378

379+
content {
374380
dynamic "http_header" {
375381
for_each = try([condition.value.http_header], [])
376382

@@ -379,23 +385,41 @@ resource "aws_lb_listener_rule" "this" {
379385
values = http_header.value.values
380386
}
381387
}
388+
}
389+
}
382390

391+
dynamic "condition" {
392+
for_each = [for condition in each.value.conditions : condition if contains(keys(condition), "http_request_method")]
393+
394+
content {
383395
dynamic "http_request_method" {
384396
for_each = try([condition.value.http_request_method], [])
385397

386398
content {
387399
values = http_request_method.value.values
388400
}
389401
}
402+
}
403+
}
390404

405+
dynamic "condition" {
406+
for_each = [for condition in each.value.conditions : condition if contains(keys(condition), "path_pattern")]
407+
408+
content {
391409
dynamic "path_pattern" {
392410
for_each = try([condition.value.path_pattern], [])
393411

394412
content {
395413
values = path_pattern.value.values
396414
}
397415
}
416+
}
417+
}
418+
419+
dynamic "condition" {
420+
for_each = [for condition in each.value.conditions : condition if contains(keys(condition), "query_string")]
398421

422+
content {
399423
dynamic "query_string" {
400424
for_each = try([condition.value.query_string], [])
401425

@@ -404,7 +428,13 @@ resource "aws_lb_listener_rule" "this" {
404428
value = query_string.value.value
405429
}
406430
}
431+
}
432+
}
407433

434+
dynamic "condition" {
435+
for_each = [for condition in each.value.conditions : condition if contains(keys(condition), "source_ip")]
436+
437+
content {
408438
dynamic "source_ip" {
409439
for_each = try([condition.value.source_ip], [])
410440

0 commit comments

Comments
 (0)