diff --git a/main.tf b/main.tf index 63dc966..5cf13ed 100644 --- a/main.tf +++ b/main.tf @@ -635,7 +635,8 @@ resource "aws_lb_listener" "frontend_http_tcp" { # Defaults to forward action if action_type not specified content { type = lookup(default_action.value, "action_type", "forward") - target_group_arn = contains([null, "", "forward"], lookup(default_action.value, "action_type", "")) ? aws_lb_target_group.main[lookup(default_action.value, "target_group_index", count.index)].id : null + target_group_arn = contains([null, "", "forward"], lookup(default_action.value, "action_type", "")) && length(lookup(lookup(default_action.value, "forward", {}), "target_groups", [])) < 2 ? aws_lb_target_group.main[lookup(default_action.value, "target_group_index", count.index)].id : null + dynamic "redirect" { for_each = length(keys(lookup(default_action.value, "redirect", {}))) == 0 ? [] : [lookup(default_action.value, "redirect", {})] @@ -710,7 +711,7 @@ resource "aws_lb_listener" "frontend_https" { # Defaults to forward action if action_type not specified content { type = lookup(default_action.value, "action_type", "forward") - target_group_arn = contains([null, "", "forward"], lookup(default_action.value, "action_type", "")) ? aws_lb_target_group.main[lookup(default_action.value, "target_group_index", count.index)].id : null + target_group_arn = contains([null, "", "forward"], lookup(default_action.value, "action_type", "")) && length(lookup(lookup(default_action.value, "forward", {}), "target_groups", [])) < 2 ? aws_lb_target_group.main[lookup(default_action.value, "target_group_index", count.index)].id : null dynamic "redirect" { for_each = length(keys(lookup(default_action.value, "redirect", {}))) == 0 ? [] : [lookup(default_action.value, "redirect", {})]