Skip to content

Commit

Permalink
Fix alb lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
saefty committed Sep 18, 2024
1 parent f263298 commit fb5dc46
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
data "aws_lb" "public" {
for_each = var.create_ingress_security_group ? { for idx, target in var.target_groups : lookup(target, "load_balancer_arn", "") => lookup(target, "load_balancer_arn", "") } : {}
for_each = var.create_ingress_security_group ? { for idx, target in var.target_groups : idx => lookup(target, "load_balancer_arn", "") } : {}
arn = each.value
}

locals {
ingress_targets = flatten(
[
for target in var.target_groups : flatten(
for idx, target in var.target_groups : flatten(
[
[
{
# allow backend_port traffic
from_port = lookup(target, "backend_port", null)
to_port = lookup(target, "backend_port", null)
protocol = "tcp"
source_security_group_id = tolist(data.aws_lb.public[lookup(target, "load_balancer_arn", null)].security_groups)[0]
source_security_group_id = tolist(data.aws_lb.public[idx].security_groups)[0]
prefix = "backend_port"
}
],
Expand All @@ -27,7 +27,7 @@ locals {
from_port = target["health_check"]["port"]
to_port = target["health_check"]["port"]
protocol = "tcp"
source_security_group_id = tolist(data.aws_lb.public[lookup(target, "load_balancer_arn", null)].security_groups)[0]
source_security_group_id = tolist(data.aws_lb.public[idx].security_groups)[0]
prefix = "health_check_port"
}
] : []
Expand Down

0 comments on commit fb5dc46

Please sign in to comment.