File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,12 +24,7 @@ resource "aws_vpc_security_group_egress_rule" "this" {
2424 description = local. nlb_sg_egress_rules [count . index ]. description
2525}
2626
27- # Optional: expose the dbx-proxy health port via the NLB so callers can reach it directly
28- # (e.g. through the PrivateLink endpoint). If the health port is already used as a regular
29- # listener port, we skip creating this additional listener/TG to avoid a conflict.
3027resource "aws_lb_target_group" "health" {
31- count = contains ([for l in var . dbx_proxy_listener : l . port ], var. dbx_proxy_health_port ) ? 0 : 1
32-
3328 name = " dbx-proxy-tg-health"
3429 port = var. dbx_proxy_health_port
3530 protocol = " TCP"
@@ -49,16 +44,21 @@ resource "aws_lb_target_group" "health" {
4944}
5045
5146resource "aws_lb_listener" "health" {
52- count = length (aws_lb_target_group. health )
53-
5447 load_balancer_arn = local. nlb_arn
5548 port = var. dbx_proxy_health_port
5649 protocol = " TCP"
5750
5851 default_action {
5952 type = " forward"
60- target_group_arn = aws_lb_target_group. health [ 0 ] . arn
53+ target_group_arn = aws_lb_target_group. health . arn
6154 }
55+
56+ tags = merge (
57+ var. tags ,
58+ {
59+ Name = " ${ var . prefix } -l-health"
60+ },
61+ )
6262}
6363
6464# One target group per listener port for simple configuration.
@@ -94,4 +94,11 @@ resource "aws_lb_listener" "this" {
9494 type = " forward"
9595 target_group_arn = each. value . arn
9696 }
97+
98+ tags = merge (
99+ var. tags ,
100+ {
101+ Name = " ${ var . prefix } -l-${ each . key } "
102+ },
103+ )
97104}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ output "nlb_target_group_arns" {
1212 description = " ARNs of the NLB target groups, keyed by listener name (plus health when created)."
1313 value = merge (
1414 { for name , tg in aws_lb_target_group . this : name => tg . arn },
15- length (aws_lb_target_group . health ) > 0 ? { health = aws_lb_target_group.health[ 0 ] .arn } : { },
15+ { health = aws_lb_target_group.health.arn },
1616 )
1717}
1818
Original file line number Diff line number Diff line change 145145 }))
146146 }))
147147 default = []
148+ validation {
149+ condition = alltrue ([for listener in var . dbx_proxy_listener : listener . port != var . dbx_proxy_health_port ])
150+ error_message = " dbx_proxy_health_port must not overlap with any dbx_proxy_listener port."
151+ }
148152}
You can’t perform that action at this time.
0 commit comments