Skip to content

Commit

Permalink
adding in traefik fix (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: Monica Hart <[email protected]>
  • Loading branch information
Mhart12 and Monica Hart authored Nov 8, 2024
1 parent 9d34959 commit e833bad
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,21 @@ resource "aws_security_group_rule" "nlb" {
security_group_id = one(aws_security_group.ecs_service[*]["id"])
}

data "aws_security_group" "traefik" {
count = local.create_security_group && var.use_traefik_security_group ? 1 : 0
name = "traefik-service"
}
resource "aws_security_group_rule" "traefik" {
count = local.create_security_group && var.use_traefik_security_group ? 1 : 0
description = "Allow inbound traffic from ALB"
type = "ingress"
from_port = var.container_port
to_port = var.container_port
protocol = "tcp"
source_security_group_id = data.aws_security_group.traefik[0].id
security_group_id = one(aws_security_group.ecs_service[*]["id"])
}

resource "aws_ecs_service" "ignore_changes_task_definition" {
count = local.ecs_service_enabled && var.ignore_changes_task_definition && !var.ignore_changes_desired_count ? 1 : 0
name = var.ecs_service_name != null ? var.ecs_service_name : module.this.id
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,10 @@ variable "sg_name" {
type = string
description = "Name of security group that the service should use."
default = null
}

variable "use_traefik_security_group" {
type = bool
description = "A flag to enable/disable adding the traefik service security group"
default = false
}

0 comments on commit e833bad

Please sign in to comment.