- Newest
- Most votes
- Most comments
In the scenario you've described, it is not possible to reach the Fargate service (service 2) from the EC2-based service (service 1) without mapping specific ports on the Fargate service.
When using Amazon ECS, especially with Fargate, you need to explicitly define the ports that your container exposes and that you want to make accessible. This is done through port mappings in the task definition.
The reason for this is that Fargate tasks run in their own isolated network environment. Without port mappings, there's no way for other services to know which ports are available or how to route traffic to the correct container and process within the Fargate task.
You will need to map all the specific ports that your Fargate service uses and needs to expose. This is a crucial part of defining how your service can be accessed. Each port that needs to be reachable should be included in the port mappings of your task definition.
If you're unsure about all the ports your application uses, you may need to review your application's configuration or code to identify all the ports it listens on or tries to use for communication.
Remember, even though your security groups allow all inbound traffic between the services, the Fargate networking model still requires explicit port mappings to route traffic correctly to your containers.
If you need more flexible communication between your services without managing specific port mappings, you might want to consider using Amazon ECS Service Connect or AWS Cloud Map for service discovery. These solutions can simplify service-to-service communication within your ECS environment.
Sources
Interconnect Amazon ECS services - Amazon Elastic Container Service
Amazon ECS Service Connect configuration overview - Amazon Elastic Container Service
Ok. Thank you, but even with the service_connect I still need port mapping.
answered 2 years ago
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated a year ago
