I’m working on a Serverless app and I’m kind of confused of what direction I should be heading. I’m trying to write a lambda function that waits for certain CloudWatch events on EC2 instances. I don’t need to listen to all EC2 instances though, only certain ones though. I’m not sure what’s the best way to do this however, I have a few ideas so far:
- Listen for all of the CloudWatch events on all EC2 instances with a single Lambda function and simply check the instance id each time.
- Attach a CloudWatch event to a SNS topic for EC2 instances I want to listen to and attach a Lambda function to that topic.
- Create a new Lambda function (programmatically) for each instance I want to listen to and trigger it on Cloud Watch events.
I’m listening for IP address assignment so I’m not quite sure what’s going to be the best for my use case. Does anyone have any tips?