An AWS Lambda function to expose AWS EC2 scheduled events as a CloudWatch Metric
- Apex Framework installed locally
- NodeJS and NPM installed locally
- An AWS IAM Lambda execution role with the appropriate permissions (see below).
- Check out this project
- Modify the
role
setting infunction.json
to point to your AWS IAM Lambda execution role with the appropriate settings. The value should be the IAM role's ARN. - Deploy the Lambda function to your AWS account using the
apex
command line tool. - In the AWS Lambda console, setup a scheduled event trigger for the deployed function
- Optional: After running the Lambda function at least once, configure a CloudWatch alert on the new metric
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstanceStatus"
],
"Resource":"*"
},
{
"Sid": "Stmt1463486944000",
"Effect": "Allow",
"Action": [
"cloudwatch:PutMetricData"
],
"Resource": [
"*"
]
}
]
}