From 135ca356b7ee259c2dadb4587d81e032a08a23c2 Mon Sep 17 00:00:00 2001 From: Sourav Kundu Date: Wed, 27 Nov 2024 14:49:32 -0600 Subject: [PATCH 1/2] updated to support traditional ecs deployment --- infra/load_balancer.tf | 21 ++++----------------- infra/ssm_parameter.tf | 6 ++---- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/infra/load_balancer.tf b/infra/load_balancer.tf index 2fb0132..6ce17a5 100644 --- a/infra/load_balancer.tf +++ b/infra/load_balancer.tf @@ -14,22 +14,8 @@ resource "aws_lb" "app_lb" { } #https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group -resource "aws_lb_target_group" "blue_target_group" { - name = "${var.name}-blue" - port = 8080 - protocol = "HTTP" - target_type = "ip" - vpc_id = aws_vpc.this.id - health_check { - matcher = "200,301,302,404" - path = "/healthcheck" - } - #checkov:skip=CKV_AWS_378: Ensure AWS Load Balancer doesn't use HTTP protocol - #This is disabled since this is non-prod. -} -#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group -resource "aws_lb_target_group" "green_target_group" { - name = "${var.name}-green" +resource "aws_lb_target_group" "target_group" { + name = var.name port = 8080 protocol = "HTTP" target_type = "ip" @@ -41,6 +27,7 @@ resource "aws_lb_target_group" "green_target_group" { #checkov:skip=CKV_AWS_378: Ensure AWS Load Balancer doesn't use HTTP protocol #This is disabled since this is non-prod. } + #https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener resource "aws_alb_listener" "listener" { #checkov:skip=CKV_AWS_2: This is disabled since this is non-prod. @@ -50,7 +37,7 @@ resource "aws_alb_listener" "listener" { protocol = "HTTP" default_action { type = "forward" - target_group_arn = aws_lb_target_group.blue_target_group.arn + target_group_arn = aws_lb_target_group.target_group.arn } lifecycle { ignore_changes = [default_action] diff --git a/infra/ssm_parameter.tf b/infra/ssm_parameter.tf index dc12e06..c41a2ff 100644 --- a/infra/ssm_parameter.tf +++ b/infra/ssm_parameter.tf @@ -7,10 +7,8 @@ resource "aws_ssm_parameter" "infra_output" { value = jsonencode({ "subnet_ids" : [for subnet in aws_subnet.private : subnet.id], "container_security_group_id" : "${aws_security_group.container_sg.id}", - "aws_lb_blue_target_group_arn" : "${aws_lb_target_group.blue_target_group.arn}", - "aws_lb_green_target_group_arn" : "${aws_lb_target_group.green_target_group.arn}", - "aws_lb_blue_target_group_name" : "${aws_lb_target_group.blue_target_group.name}", - "aws_lb_green_target_group_name" : "${aws_lb_target_group.green_target_group.name}", + "aws_lb_target_group_arn" : "${aws_lb_target_group.target_group.arn}", + "aws_lb_target_group_name" : "${aws_lb_target_group.target_group.name}", "aws_lb_listener" : "${aws_alb_listener.listener.arn}", "aws_lb" : "${aws_lb.app_lb.arn}", "aws_vpc_id" : "${aws_vpc.this.id}", From 33ebbbedd2a2c7b1aa8d8f5b01b2853581ac71f1 Mon Sep 17 00:00:00 2001 From: Sourav Kundu Date: Wed, 27 Nov 2024 15:19:16 -0600 Subject: [PATCH 2/2] more fixes for #114 --- infra/load_balancer.tf | 3 --- 1 file changed, 3 deletions(-) diff --git a/infra/load_balancer.tf b/infra/load_balancer.tf index 6ce17a5..a980759 100644 --- a/infra/load_balancer.tf +++ b/infra/load_balancer.tf @@ -39,7 +39,4 @@ resource "aws_alb_listener" "listener" { type = "forward" target_group_arn = aws_lb_target_group.target_group.arn } - lifecycle { - ignore_changes = [default_action] - } } \ No newline at end of file