Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally configure internal service via its load balancer #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module "fargate" {
cpu = "256" # String, Required: CPU units used by the tasks
memory = "512" # String, Required: memory used by the tasks
replicas = 5 # Number, Required: amount of task replicas needed for the ecs service
internal = false # Boolean, Optional: allows to specify that the service will live in a private subnet and use an internal load balancer

registry_retention_count = 15 # Number, Optional: sets how many images does the ecr registry will retain before recycling old ones. default = 20
logs_retention_days = 14 # Number, Optional: sets how many days does the cloud watch log group will retain logs entries before deleting old ones. default = 30
Expand Down
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ resource "aws_lb_target_group" "this" {
}

resource "aws_lb" "this" {
count = local.services_count > 0 ? local.services_count : 0
count = local.services_count > 0 ? local.services_count : 0
internal = lookup(local.services[count.index], "internal", false)

name = "${var.name}-${terraform.workspace}-${local.services[count.index].name}-alb"
subnets = slice(local.vpc_public_subnets_ids, 0, min(length(data.aws_availability_zones.this.names), length(local.vpc_public_subnets_ids)))
subnets = lookup(local.services[count.index], "internal", false) ? slice(local.vpc_private_subnets_ids, 0, min(length(data.aws_availability_zones.this.names), length(local.vpc_private_subnets_ids))) : slice(local.vpc_public_subnets_ids, 0, min(length(data.aws_availability_zones.this.names), length(local.vpc_public_subnets_ids)))
security_groups = [aws_security_group.web.id]
}

Expand Down