
147
1 from chalice import Chalice, Rate
2
3 app = Chalice(app_name="helloworld")
4
5 # Automatically runs every 5 minutes
6 @app.schedule(Rate(5, unit=Rate.MINUTES))
7 def periodic_task(event):
8 return {"hello": "world"}
It can also run event-driven lambdas.
1 from chalice import Chalice
2
3 app = Chalice(app_name="helloworld")
4
5 # Whenever an object uploads to 'mybucket'
6 # this lambda function will be invoked.
7
8 @app.on_s3_event(bucket='mybucket')
9 def handler(event):
10 print("Object uploaded for bucket: %s, key: %s"
11 % (event.bucket, event.key))
Google Cloud Functions
Google Cloud Functions have mu in common with AWS Lambda. ey work by invoking a