diff --git a/alb_no_logs.tf b/alb_no_logs.tf index 57e4743..d9e8cd7 100644 --- a/alb_no_logs.tf +++ b/alb_no_logs.tf @@ -62,7 +62,7 @@ resource "aws_lb_listener" "frontend_http_tcp_no_logs" { count = "${var.create_alb && !var.logging_enabled ? var.http_tcp_listeners_count : 0}" default_action { - target_group_arn = "${aws_lb_target_group.main_no_logs.*.id[lookup(var.http_tcp_listeners[count.index], "target_group_index", 0)]}" + target_group_arn = "${aws_lb_target_group.main_no_logs.*.id[lookup(var.http_tcp_listeners[count.index], "target_group_index", count.index)]}" type = "forward" } } @@ -76,7 +76,7 @@ resource "aws_lb_listener" "frontend_https_no_logs" { count = "${var.create_alb && !var.logging_enabled ? var.https_listeners_count : 0}" default_action { - target_group_arn = "${aws_lb_target_group.main_no_logs.*.id[lookup(var.https_listeners[count.index], "target_group_index", 0)]}" + target_group_arn = "${aws_lb_target_group.main_no_logs.*.id[lookup(var.https_listeners[count.index], "target_group_index", count.index)]}" type = "forward" } } diff --git a/alb_w_logs.tf b/alb_w_logs.tf index 03bb148..959bdd5 100644 --- a/alb_w_logs.tf +++ b/alb_w_logs.tf @@ -68,7 +68,7 @@ resource "aws_lb_listener" "frontend_http_tcp" { count = "${var.create_alb && var.logging_enabled ? var.http_tcp_listeners_count : 0}" default_action { - target_group_arn = "${aws_lb_target_group.main.*.id[lookup(var.http_tcp_listeners[count.index], "target_group_index", 0)]}" + target_group_arn = "${aws_lb_target_group.main.*.id[lookup(var.http_tcp_listeners[count.index], "target_group_index", count.index)]}" type = "forward" } } @@ -82,7 +82,7 @@ resource "aws_lb_listener" "frontend_https" { count = "${var.create_alb && var.logging_enabled ? var.https_listeners_count : 0}" default_action { - target_group_arn = "${aws_lb_target_group.main.*.id[lookup(var.https_listeners[count.index], "target_group_index", 0)]}" + target_group_arn = "${aws_lb_target_group.main.*.id[lookup(var.https_listeners[count.index], "target_group_index", count.index)]}" type = "forward" } }