make connection from service running in one ECS cluster to another ECS cluster

0

I have 2 ECS clusters say cluster A and cluster B each having multiple ECS services running like service-a1, service-a2, etc and service-b1, service-b2, etc respectively. Each service is running multiple tasks and tasks have mulitple containers exposed on different ports. I want to make a call from service-a1 to service-b2 without worrying about which task receives the request. Each ECS task is running on EC2. NOTE: I dont want to make connection specific ECS task. I know that we can do it by using public IP or Public EC2 DNS with specific port of the container. I want it to be at ECS service level.

2 Answers
1

Hello.

I think there are two ways.
The first method is to connect ELB to an ECS service and access from other ECS services via ELB.
If you are someone who regularly sets up ELB, I think you will be able to set it up right away as it is not that difficult.
Although only when using ALB, it can also support path-based routing and host-based routing.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-load-balancing.html

The second method is to use ECS Service Connect or ECS service discovery.
Service Discovery registers the task's IP in Route53's private hosted zone via Cloud Map.
It is possible to communicate directly with tasks based on the results of name resolution in Route53.
Service Connect allows you to define endpoints for your services and communicate through them, eliminating the need to directly manage service addresses and port numbers.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/interconnecting-services.html

profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions