Skip to content

Commit

Permalink
add traefik security group
Browse files Browse the repository at this point in the history
  • Loading branch information
tnordloh committed Nov 8, 2024
1 parent b795a97 commit 52da4c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,20 @@ resource "aws_security_group_rule" "alb" {
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_security_group_rule" "nlb" {
count = local.create_security_group && var.use_nlb_cidr_blocks ? 1 : 0
description = "Allow inbound traffic from NLB"
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ variable "container_port" {
default = 80
}

variable "use_traefik_security_group" {
type = bool
description = "A flag to enable/disable adding the traefik service security group"
default = false
}
variable "use_nlb_cidr_blocks" {
type = bool
description = "A flag to enable/disable adding the NLB ingress rule to the service security group"
Expand Down

0 comments on commit 52da4c6

Please sign in to comment.