Schedule Lambda On Cron Expression Triggers
- AWS, Cloud, DevOps, Technology
Lambda is an Amazon Web Services (AWS) masterpiece which helps in leveraging compute services for a duration of seconds to minutes and hence reduces the infrastructure costs manifolds and its maintenance.
The Cron expressions are created, evaluated and triggered using Cloudwatch Management Console. The possible cron expressions for AWS Lambda are discussed in this link. In this blog, you can see that Lambda is triggered, based on Cron expressions.
There are two ways to create Cron expressions triggers, demonstrated below.
First, go to Cloudwatch Management Console > Rules > Schedule. Specify the desired Cron expressions and Add target to a pre-created Lambda Function.
Second, visit Lambda Management Console > Create a Lambda function > Select Blueprint (Choose the Blueprint you want) > Configure triggers (Choose CloudWatch Events – Schedule) as following:
Enter the Rule Name, Description, Schedule expression and then enable the trigger:
In the next stage, enter the desired Lambda Function which you need to perform. The cron expression can be validated in CloudWatch Console > Rules.
It will serve as a centralized place for keeping and monitoring of all the cron expressions used in the infrastructure.
Hope this blog will come in handy when you schedule Lambda On Cron Expression Triggers!
A quick note about this approach – AWS CloudWatch Rules has a limit of 100 rules (scheduled tasks) per Region per Account. Therefore, don’t think of this as an ad hoc scheduling tool.