Skip to content

Commit

Permalink
fix initial apply w/o target
Browse files Browse the repository at this point in the history
  • Loading branch information
saefty committed Sep 13, 2024
1 parent 779a64e commit f263298
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data "aws_lb" "public" {
for_each = var.create_ingress_security_group ? toset([for target in var.target_groups : lookup(target, "load_balancer_arn", "")]) : []
for_each = var.create_ingress_security_group ? { for idx, target in var.target_groups : lookup(target, "load_balancer_arn", "") => lookup(target, "load_balancer_arn", "") } : {}
arn = each.value
}

Expand Down Expand Up @@ -64,7 +64,8 @@ module "sg" {
}

resource "aws_security_group_rule" "trusted_egress_attachment" {
for_each = { for route in local.ingress_targets : "${route["prefix"]}-${route["source_security_group_id"]}" => route }
depends_on = [data.aws_lb.public]
for_each = { for route in local.ingress_targets : "${route["prefix"]}-${route["protocol"]}-${route["from_port"]}-${route["to_port"]}" => route }
type = "egress"
from_port = each.value["from_port"]
to_port = each.value["to_port"]
Expand Down

0 comments on commit f263298

Please sign in to comment.