Enabling governance using EC2 tags and Lambda

Governance has always been of one of the key issues faced by cloud administrators, especially when it comes to tracking EC2 instances for cost and compliance purposes. In this use case, we are going to automate the tagging of EC2 instances and its corresponding resources using a simple Lambda function used in conjuncture with AWS CloudTrail and CloudWatch. The function will ensure that users can work only on those resources that they have created based on resource tags.

How it all works is as follows. We start off by creating a trail in CloudTrail to track all the API calls and events taking place within the AWS account. Next, we create a dummy user in IAM, which will not only have permissions ...

Get Mastering AWS Lambda now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.