Skip to content

Commit

Permalink
fix: correctly setup security group
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmorehouse committed Mar 7, 2024
1 parent 5ace12e commit 4f7b8e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions create-an-aws-ecs-byoc-app/components/ecs-service/alb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ module "ingress" {

target_groups = {
api = {
name_prefix = "api-"
name_prefix = "api"
protocol = "HTTP"
port = 8080
backend_port = var.container_port
target_type = "ip"
create_attachment = false
deregistration_delay = 5
load_balancing_cross_zone_enabled = true

health_check = {
enabled = true
interval = 10
Expand Down
7 changes: 4 additions & 3 deletions create-an-aws-ecs-byoc-app/components/ecs-service/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module "service" {
name = var.service_name
cluster_arn = var.cluster_arn

desired_count = 3
cpu = 1024
memory = 4096

Expand Down Expand Up @@ -43,16 +44,16 @@ module "service" {
service = {
target_group_arn = module.ingress.target_groups["api"].arn
container_name = "api"
container_port = 8080
container_port = var.container_port
}
}

subnet_ids = data.aws_subnets.private.ids
security_group_rules = {
ingress_http = {
type = "ingress"
from_port = 0
to_port = 0
from_port = var.container_port
to_port = var.container_port
protocol = "tcp"
description = "Service port"
source_security_group_id = module.ingress.security_group_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Service config
variable "container_port" {
default = 8080
}

variable "service_name" {
type = string
Expand Down

0 comments on commit 4f7b8e9

Please sign in to comment.