From 720b9dca774c82ecc7215cd2385456033c2fc4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Badgen?= Date: Tue, 3 Mar 2020 10:04:52 -0300 Subject: [PATCH 1/3] Optionally configure internal service via its load balancer --- main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 5c81ea8..407271e 100644 --- a/main.tf +++ b/main.tf @@ -283,9 +283,10 @@ resource "aws_lb_target_group" "this" { resource "aws_lb" "this" { 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] } From 0ff6f112a8ea9f5c9ba775da241a980c2087028c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Badgen?= Date: Tue, 3 Mar 2020 10:51:38 -0300 Subject: [PATCH 2/3] Updated documentation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 939b951..c0203ff 100644 --- a/README.md +++ b/README.md @@ -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 From 156ed1ee812340b192409d137c8accc7f2add5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Badgen?= Date: Tue, 3 Mar 2020 11:25:22 -0300 Subject: [PATCH 3/3] Reformat due to build failure --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 407271e..a03887b 100644 --- a/main.tf +++ b/main.tf @@ -282,8 +282,8 @@ resource "aws_lb_target_group" "this" { } resource "aws_lb" "this" { - count = local.services_count > 0 ? local.services_count : 0 - internal = lookup(local.services[count.index], "internal", false) + 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 = 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)))