I am using AWS ECS Fargate, I am currently using service discovery to allow my tasks to communicate with eachother. I have an issue where my tasks can only communicate if I place this security group on them
resource "aws_security_group" "ecs_config_service" {
name = "staging-ecs-config-service"
description = "We need this so our services can communicate"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [
"0.0.0.0/0"
]
}
}
If I remove this security group and only allow traffic from my load balancer the containers can't communicate. This feels like a bit of a security risk allowing traffic from anywhere but I'm not sure how else I can allow my tasks to communicate.
My ECS cluster sits within a private subnet in my VPC.
Is there something I am missing with my setup?