This will help users to find over all deploy and deleted EC2
- Enable CloudTrail Logs
- Start CloudTrail logs to deliver to Cloudwatch
- Create IAM Role for Lambda and DynamoDB (Provide Permission for Lambda and DyanamoDB access)
- Create a Lambda Function to Store Data in DynamoDB (paste provided Code "index.js" in lambda function)
- Now we will stream the logs with Lambda (Create Lambda subscription filter)
- Choose Lambda function name
- Log format (Cloudtrail)
- Subscription filter pattern - optional {
$.eventName = "RunInstances" || $ .eventName = "TerminateInstances" } - Finally create subscription
- Create DynamoDB Tables
- instance-terminate-state
- instance-terminate-stop
- Now deploy few test EC2 and delete those. EC2 will be populated in DynamoDB tables