Can an ECS service / ASG instance add its own IP to an a Systems Manager Parameter Store entry on bootup?

97 Views Asked by At

I want nodes to add their own ip to a list at a key, so that other nodes joining the cluster can discover them. The issue w/ using the supported CloudMap registration for doing this, is that doesn't seem very dynamic. I want the list to start off initially empty (for the first node), and then grow or shrink as appropriate.

1

There are 1 best solutions below

0
On
  1. You can have a Daemon ECS service for this (not in replica mode). This make sure you have always a your program running once ECS container instance comes up.

  2. Then you can enable container meta-data to get HostPublicIPv4Address.

  3. And use AWS SDK to post to what-ever store you want to.

Upon trying this, it was observed that there is always an overlap when multiple instance come up. So you should better use proper database (which has transaction support) to store those IPs.This way two Daemon processes can fight for DB lock.