Scheduling Lambda Functions Using CloudWatch Events

I was working on a new Alexa Skill when I learned that you can schedule lambda functions using Cloudwatch events. This is great for kicking off a function at regular intervals, like every 15 minutes, or a certain time, like 5:00pm Monday through Friday.

Using Cloudwatch to Trigger Lambda Function at Scheduled Times

You can create the scheduled Cloudwatch Events in many ways. Using the AWS Console there are at least 2 ways. Either when adding a trigger for the Lambda Function or directly in CloudWatch as shown here. I am creating a CloudWatch Event rule that triggers a Lambda Function every 15 minutes.

Cloudwatch Event Rule to Trigger Lambda Function Every 15 Minutes

You can specify rules using either a RATE or CRON Expression.

Creating an event every 15 minutes.

aws events put-rule --schedule-expression "rate(15 minutes)" --name MyRule

Creating an event to run every Monday through Friday at 5:00pm.

aws events put-rule --schedule-expression "cron(0 17 ? * MON-FRI *)" --name MyRule

View more in the documentation.