Skip to content

Commit 1363665

Browse files
committed
Fixing aws_alb_listener http_redirect
1 parent 5618344 commit 1363665

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

operations/deployment/terraform/modules/aws/ecs/aws_ecs_networking.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,28 @@ resource "aws_alb_listener_rule" "redirect_based_on_path" {
118118

119119
resource "aws_alb_listener" "http_redirect" {
120120
count = var.aws_ecs_lb_redirect_enable && !contains(local.aws_ecs_lb_port,80) ? 1 : 0
121-
load_balancer_arn = "${aws_alb.ecs_lb.id}"
121+
load_balancer_arn = aws_alb.ecs_lb.id
122122
port = "80"
123123
protocol = "HTTP"
124124

125125

126126
default_action {
127-
type = var.aws_certificate_enabled != "" ? "redirect" : "forward"
128-
target_group_arn = var.aws_certificates_selected_arn != "" ? null : aws_alb_target_group.lb_targets[0].id
127+
type = var.aws_certificate_enabled ? "redirect" : "forward"
128+
target_group_arn = var.aws_certificate_enabled ? null : aws_alb_target_group.lb_targets[0].id
129129

130130
dynamic "redirect" {
131-
for_each = var.aws_certificates_selected_arn != "" ? [1] : [0]
131+
for_each = var.aws_certificate_enabled ? [1] : [0]
132132
content {
133133
port = 443
134134
protocol = "HTTPS"
135135
status_code = "HTTP_301"
136136
}
137137
}
138138
}
139+
depends_on = [
140+
aws_alb.ecs_lb,
141+
aws_alb_target_group.lb_targets
142+
]
139143
}
140144

141145
resource "aws_security_group_rule" "incoming_alb_http" {

0 commit comments

Comments
 (0)