From 99aadad0675b3ae3b908a74bb444583a654583c0 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Wed, 15 Jun 2022 15:46:05 -0700 Subject: [PATCH] Avoid duplicated security rules (fix #23) (#49) --- main.tf | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/main.tf b/main.tf index ed76f77..1556dd1 100644 --- a/main.tf +++ b/main.tf @@ -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