Home > front end >  Notify AWS all ECS instances when file in S3 changes
Notify AWS all ECS instances when file in S3 changes

Time:10-31

Wanted to know is there a way to notify all ECS instances in case a file is uploaded or newer version is uploaded to S3?

As far as I know, SNS, SQS or activity will only notify the first instance that will recieve the notification/message.

CodePudding user response:

SNS is the standard way to broadcast notifications; this doc describes how to configure it with S3.

If all listeners are webserver, then the easiest way to connect them is with an HTTP Notification from SNS.

You'll need to make the following changes to your application:

  • On startup, make sure that your server's endpoint is subscribed to the SNS topic. You can't simply subscribe a load-balancer endpoint, because it will distribute the traffic; not everything will receive it.
  • Your application must listen for the subscription confirmation request and confirm the subscription.
  • Your application then listens for the notification request, and does whatever it needs to do.

Alternatively, you can subscribe SQS queues -- one per interested server -- but that would become a management chore if you have an auto-scaled fleet.

  • Related