I am trying to allow an ECS task on one security group to access an EC2 instance on another security group so that I can access a mongo database hosted on the EC2 instance. Both security groups are under the same VPC.
I have added an inbound rule to the security group of the EC2 instance and set the source to the security group of the ECS fargate task like so:
However when I then try that, this does not allow access. Only when I use the ECS task’s public or private IP does it actually allow it through. I have confirmed that the ECS task is indeed on the security group that is being allowed access to the EC2 instance. Is it possible to just allow a security group access? I want any ECS task I start to be allowed access without me needing to manually add the IP to the rules if possible.