Skip to content

Commit 7fcda29

Browse files
authored
Merge pull request #9 from mxfactorial/feature/internal-lb
support internal lb
2 parents 4dc8745 + 5b248af commit 7fcda29

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Check the section "Other modules that you may need to use this module" for detai
5858
* security_groups: (Optional) The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used.
5959
* assign_public_ip: (Optional) Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false.
6060
* lb_health_check_path: (Optional) Health check path for the Load Balancer
61+
* internal_lb: (Optional) Sets ECS service load balancer to internal and disables ECS service public ip assignment. Default false
6162

6263
## Output values
6364

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ resource "aws_ecs_service" "service" {
7272
network_configuration {
7373
security_groups = concat([aws_security_group.ecs_tasks_sg.id], var.security_groups)
7474
subnets = var.private_subnets
75-
assign_public_ip = var.assign_public_ip
75+
assign_public_ip = var.internal_lb ? false : var.assign_public_ip
7676
}
7777
load_balancer {
7878
target_group_arn = aws_lb_target_group.lb_tg.arn
@@ -216,9 +216,9 @@ resource "aws_security_group" "lb_sg" {
216216
# ---------------------------------------------------------------------------------------------------------------------
217217
resource "aws_lb" "lb" {
218218
name = "${var.name_preffix}-lb"
219-
internal = false
219+
internal = var.internal_lb
220220
load_balancer_type = "application"
221-
subnets = var.public_subnets
221+
subnets = var.internal_lb ? var.private_subnets : var.public_subnets
222222
security_groups = [aws_security_group.lb_sg.id]
223223
enable_deletion_protection = false
224224
enable_cross_zone_load_balancing = true

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,10 @@ variable "lb_health_check_path" {
130130
description = "(Optional) Health check path for the Load Balancer"
131131
type = string
132132
default = "/"
133-
}
133+
}
134+
135+
variable "internal_lb" {
136+
description = "(Optional) Sets ECS service load balancer to internal and disables ECS service public ip assignment. Default false"
137+
type = bool
138+
default = false
139+
}

0 commit comments

Comments
 (0)