Alt Text
Alt Text

Create Cron Jobs on AWS Lambda with cloudwatch event

Quick start aws-chalice

A very simple example of creating lambda function with cloudwatch event using aws-chalice. It provides an optional of how to create lambda function beyond aws-cdk (eg. python lamdbda cron)

What’s In This Document

🚀 Create new chalice project

⚡ $ chalice new-project lambda-cron
⚡ $ cd lambda-cron/

🚀 Create the functions in


from datetime import datetime
from chalice import Chalice

app = Chalice(app_name='lambda-cron')
app.debug = True

#@app.schedule('cron(0 18 ? * MON-FRI *)')
@app.schedule('cron(* * ? * * *)')
def cron_tab(event):
print(f"{}: I'm running!")

🚀 Config lambda fuction attributes

  • Here is just config lambda timeout
⚡ $ cat .chalice/config.json 
"version": "2.0",
"app_name": "lambda-cron",
"stages": {
"dev": {
"lambda_timeout": 300

🚀 Deploy chalice to create cloudwatch event which trigger lambda cron

⚡ $ chalice deploy
Creating deployment package.
Creating IAM role: lambda-cron-dev
Creating lambda function: lambda-cron-dev-cron_tab
Resources deployed:
- Lambda ARN: arn:aws:lambda:ap-northeast-2:111111111111:function:lambda-cron-dev-cron_tab
  • Note: Chalice auto create IAM role lambda-cron-dev base on the need of the function, we can disable by adding "manage_iam_role": false but you must provide the IAM ARN in config.json eg. "iam_role_arn": "arn:aws:iam::111111111111:role/lambda-cron-dev"

🚀 Check result

  • Lambda function with Event Bridge trigger
Alt Text
Alt Text
  • Cloudwatch event rule
Alt Text
Alt Text
  • Cloudwatch log group
Alt Text
Alt Text

🚀 Clean up

⚡ $ chalice delete
Deleting function: arn:aws:lambda:ap-northeast-2:111111111111:function:lambda-cron-dev-cron_tab
Deleting IAM role: lambda-cron-dev

Visit to get more

🌠 Blog · Web · Linkedin · Group · Page · Twitter 🌠




Awesome Devops || CloudOpz

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

11 Mistakes which every PHP developer should avoid while programming

php development, php developers, php application development

install kubeflow in on-prem

All about Gazebo 9 with ROS

Send Push Notification From Rails To iOS App

Push Notification on Mobile Phone

Transcribe Japanese using Go and Machine Learning APIs

Double pipe operator

Q#50: Function to count tuple elements

What are some of the best ways to learn programming?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vu Dao

Vu Dao

Awesome Devops || CloudOpz

More from Medium

AWS Dynamo DB Local Development using Localstack and Docker

AWS — API Gateway and its use cases

Let’s Encrypt Certificates with AWS

Part 2 : AWS SNS — How to send message through your application using aws simple notification…