/sam-cloudtrail-ec2

Be notified of EC2 instance events 🚀 from any region 🗺️ via a Cloudtrail CloudWatch Logs subscription filter !Rules

Primary LanguageJavaScriptMIT LicenseMIT

Prerequisites

Setup Cloudtrail to log to CloudTrail/DefaultLogGroup.

Setup an SNS Topic with subscribers who would like to be informed when an EC2 is launched in any AWS region.

SAM CLI and sam deploy -g.

How do I know if I have deployed this?

Cloudwatch subscription

There should be a subscription active upon CloudTrail/DefaultLogGroup.

Btw it takes ~15 minutes for Cloudtrail to capture and log the event in CloudWatch in my experience.

Why not use Cloudwatch events?

https://aws.amazon.com/premiumsupport/knowledge-center/ec2-email-instance-state-change/ is a good tip, but what they don't tell you, is that you need to deploy in EVERY REGION for it to work.

Maintenance consideration

Cloudtrail bucket isn't used by this function, so consider putting an expiration on the objects.

Similarly CloudTrail/DefaultLogGroup can get large, put a retention policy on it.