Skip to content

AWS Lambda Function to Count Number of Running EC2 Instances and Publish to Cloudwatch

Notifications You must be signed in to change notification settings

MarkRoddy/count-ec2-instances

Repository files navigation

count-ec2-instances

An AWS Lambda function to count the number of EC2 instances and publish to CloudWatch because why exactly can't I do that with CloudWatch out of the box?

Deployment

Assuming you have a ~/.aws/config with some pretty powerful permssions, you only need run make deploy. You'll most likely get tripped up on setting up IAM roles and permissions which you may not have permission to list/create/edit/etc. If you hit this problem, you may wish to create the CountEc2InstancesLambdaRole role manually applying the supplied role policy. You can then run make deployment-package.zip and ./create-or-update-function.sh

Functionality

It's pretty straight forward. Every five minutes we will query the EC2 API for instances in the running state and post the value to CloudWatch via the metric NumberRunningInstances.

About

AWS Lambda Function to Count Number of Running EC2 Instances and Publish to Cloudwatch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published