How to convert your Lambda Function into a CronJob

  1. Open the CloudWatch console https://us-west-2.console.aws.amazon.com/cloudwatch/home?region=us-west-2#
  2. Make sure you’re in your desired region, if not change it
  3. On the left panel, click on Events —> Rules
  4. Since CloudWatch Events is now EventBridge, we’ll go to Amazon EventBridge —> https://eu-west-1.console.aws.amazon.com/events/home?region=eu-west-1#/rules
  5. Click on Create rule
  6. Give it an appropriate name, usually the same as function name
  7. At the bottom select the option: Schedule (A rule that runs on time)
  8. Provide a time interval. Your Lambda Function will execute based on this time interval i.e everyday / every week / every month.
  9. A cron expression is a combination of 6 values that tell EventBridge when to run the rule. For example cron(0 12 ? *) runs the rule every day at 12:00pm UTC+0.
  10. Select the Target Type as AWS service
  11. Select the Target as Lambda function
  12. Now Select the lambda function, if it’s not there, click on the refresh button right beside or check if you’ve pushed your Lambda function into amplify properly
  13. Create a tag for easier search later on if you want
  14. Review all the config and create