Skip to content

Commit

Permalink
Avoid duplicated security rules (fix #23) (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atry authored Jun 15, 2022
1 parent ec9235a commit 99aadad
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,8 @@ resource "aws_security_group_rule" "egress" {
cidr_blocks = ["0.0.0.0/0"]
}

resource "aws_security_group_rule" "ingress_through_http" {
for_each = toset(module.ecs-alb.lb_http_tgs_ports)
security_group_id = aws_security_group.ecs_tasks_sg.id
type = "ingress"
from_port = each.key
to_port = each.key
protocol = "tcp"
source_security_group_id = module.ecs-alb.aws_security_group_lb_access_sg_id
}

resource "aws_security_group_rule" "ingress_through_https" {
for_each = toset(module.ecs-alb.lb_https_tgs_ports)
resource "aws_security_group_rule" "ingress_through_http_and_https" {
for_each = toset(concat(module.ecs-alb.lb_https_tgs_ports, module.ecs-alb.lb_http_tgs_ports))
security_group_id = aws_security_group.ecs_tasks_sg.id
type = "ingress"
from_port = each.key
Expand Down

0 comments on commit 99aadad

Please sign in to comment.