I have a setup: ALB in front of ECS. I have a module of ecs and one for alb:
The egress rule of the ALB of alb_sg:
egress {
description = "Traffic from ALB to ECS"
from_port = 80
to_port = 80
protocol = "tcp"
security_groups = [var.ecs_sg] //comes from output from ecs stack
}
Now in ECS I have something like this for its security group (ecs_sg)
ingress {
description = "Allow ALB to ECS"
from_port = 80
to_port = 80
protocol = "tcp"
security_groups = [var.alb_sg] //comes from output from alb stack
}
Now I have some error:
│ Error: Cycle: module.ecs.var.alb_sg (expand), module.ecs.aws_security_group.ecs_sg, module.ecs.output.ecs_sg (expand), module.alb.var.ecs_sg (expand), module.alb.aws_security_group.alb_sg, module.alb.output.alb_sg (expand)
How can this be solved? Thanks
The solution is to create the SGs and SG rules separately. You can define the SG rules by using the aws_security_group_rule resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With