Skip to content

Commit 8f228bf

Browse files
authored
Add optional port 80 on internal LB
1 parent 0a6aba0 commit 8f228bf

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

_variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ variable "architecture" {
1414
default = "x86_64"
1515
description = "Architecture to select the AMI, x86_64 or arm64"
1616
}
17+
1718
variable "volume_type" {
1819
default = "gp2"
1920
description = "The EBS volume type"
@@ -132,6 +133,12 @@ variable "alb_internal_ssl_policy" {
132133
description = "The name of the SSL Policy for the listener. Required if protocol is HTTPS or TLS."
133134
}
134135

136+
variable "alb_internal_enable_http" {
137+
type = bool
138+
default = false
139+
description = "If listenter in port 80 should be enable for internal LB"
140+
}
141+
135142
variable "alb_drop_invalid_header_fields" {
136143
default = true
137144
type = bool

alb-internal.tf

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ resource "aws_lb" "ecs_internal" {
3333
)
3434
}
3535

36+
37+
38+
resource "aws_lb_listener" "ecs_optional_http_internal" {
39+
count = var.alb_internal && var.alb_internal_enable_http ? 1 : 0
40+
41+
load_balancer_arn = aws_lb.ecs_internal[0].arn
42+
port = "80"
43+
protocol = "HTTP"
44+
45+
default_action {
46+
type = "forward"
47+
target_group_arn = aws_lb_target_group.ecs_default_https_internal[0].arn
48+
}
49+
50+
tags = merge(
51+
var.tags,
52+
{
53+
"Terraform" = true
54+
},
55+
)
56+
}
57+
58+
3659
resource "aws_lb_listener" "ecs_https_internal" {
3760
count = var.alb_internal ? 1 : 0
3861

@@ -46,7 +69,6 @@ resource "aws_lb_listener" "ecs_https_internal" {
4669
type = "forward"
4770
target_group_arn = aws_lb_target_group.ecs_default_https_internal[0].arn
4871
}
49-
5072
tags = merge(
5173
var.tags,
5274
{

0 commit comments

Comments
 (0)