Skip to content

Commit

Permalink
T3 - Fix Hardcoded Container Port
Browse files Browse the repository at this point in the history
  • Loading branch information
felipefreitassilva committed Dec 3, 2024
1 parent e9948bb commit 6df3ff8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions infra/alb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module "alb" {

listeners = {
http = {
port = 8000
port = local.container_port
protocol = "HTTP"

forward = {
Expand All @@ -26,7 +26,7 @@ module "alb" {
target_groups = {
ecs = {
backend_protocol = "HTTP"
backend_port = 8000
backend_port = local.container_port
target_type = "ip"
deregistration_delay = 5
load_balancing_cross_zone_enabled = true
Expand Down
6 changes: 3 additions & 3 deletions infra/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ resource "aws_ecs_task_definition" "task" {
image = "${local.user_id}.dkr.ecr.${local.region}.amazonaws.com/${local.container_name}:latest"

portMappings = [{
containerPort = 8000
hostPort = 8000
containerPort = local.container_port
hostPort = local.container_port
protocol = "tcp"
}]
}])
Expand All @@ -46,7 +46,7 @@ resource "aws_ecs_service" "ecs_service" {
load_balancer {
target_group_arn = module.alb.target_groups["ecs"].arn
container_name = local.container_name
container_port = 8000
container_port = local.container_port
}

tags = local.tags
Expand Down
4 changes: 2 additions & 2 deletions infra/security_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ resource "aws_security_group" "security_group" {
# API
ingress {
description = "API"
from_port = 8000
to_port = 8000
from_port = local.container_port
to_port = local.container_port
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
Expand Down

0 comments on commit 6df3ff8

Please sign in to comment.