How to get one ECS EC2 cluster to call the Express server on another ECS EC2 instance on the same private subnet

0

Hey guys, I've been trying to figure out how to make a REST call from one ECS EC2 instance to another. To give some context. These ECS clusters are both on the same private subnet. One instance is acting as our public API and the other instance is acting as a secondary service that the public API calls.

Both ECS instances are setup in awsvpc network mode.

I thought that it would be possible to call one instance from another by using the private ip, but this seems to fail. In order to make the request, I'm using axios on an Express server.

After I deploy the API and call the endpoint that then calls the endpoint to the other service, it hangs.

I ran the Reachability Analyzer using the network interfaces and came back successful.

Any suggestions on how I can go about doing this?

Thanks in advance!

1개 답변
0
수락된 답변

For anybody that ends up here looking for a solution.

  1. You can call the private ip of the instance from one ECS EC2 instance to another.
  2. In order to update the get the new private IP after re-deploying the task, I attached the service to a network load balancer in IP mode. Then I call the domain of the NLB for the service calling the other service.
vshhh
답변함 5달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠