0

I need to send data from 1 ecs container to another. How can I do that? There is AWS EventBridge that allows me to send data from ECS container to EventBridge. But I could not figure out how to send this data to the other ECS container from EventBridge.

P.S. I have node applications running in ECS containers. I am using HTTP API Gateway and Application Load Balancer (ALB)

Answers to questions asked in comments

  • What kind of data? Text Data
  • How big is one msg? Small. Just simple objects
  • Does it have to be real-time or not? No
Vinit Khandelwal
  • 490
  • 8
  • 20

1 Answers1

1

I need to send data from 1 ecs container to another. How can I do that?

Usually, when you want your microservices to communicate with each other, an SQS is a preferred choice. The use of the SQS allows you to fully de-couple the producer and the consumer of the messages.

In your case, one container would publish messages to the queue, while the second container would pull for the messages on a fixed schedule. For these to work, both containers would need to have permissions in their task executions role to access the SQS and use AWS SDK to publish and receive the message.

There are other choices as well, such as SNS and EventBridge as you noted. However, due to its simplicity, SQS is often the first choice to consider.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • I want to invoke an endpoint of the other docker in ECS. It's an API service. I have integrated it with HTTP API Gateway. I want one service to finish it's task and then send request to another service (ECS nodejs docker) to carry its task. SQS will require me to make the ECS continuously send requests to SQS to check if some request is there or not – Vinit Khandelwal Oct 12 '20 at 12:31
  • @VinitKhandelwal So you SNS. It can publish to any HTTP endpoint, and no polling is required. – Marcin Oct 12 '20 at 12:33
  • How about I use EventBridge. I make a rule in EventBridge that invokes API Gateway Endpoint. Is that possible? – Vinit Khandelwal Oct 13 '20 at 19:36
  • @VinitKhandelwal Yes, you can also use API gateway in EB as target. But with this approach you have extra step between your first container and the second one (the api gateway). With SNS, you don't need it. SNS can directly push messages to http endpoints. – Marcin Oct 14 '20 at 00:16
  • SNS can do that? Even if my ECS cluster is in a VPC with private subnets? – Vinit Khandelwal Oct 14 '20 at 04:01
  • @VinitKhandelwal If its private subnet, then it sadly can't. – Marcin Oct 14 '20 at 04:05
  • So, EventBridge is a good option? Can the same be achieved with redis pubsub? – Vinit Khandelwal Oct 14 '20 at 04:31