Because as you know I hate doing complicated maintenance, I've started adding this function to the bottom of my Chalice app.py file:
"""
This function allows me to use the same Lambda for HTTP (Api gateway), CRON (Cloudwatch poll) and
Batch (Kinesis - putting an item in the kinesis stream triggers a call to this function)
"""
def command_router(event, context):
if 'requestContext' in event:
logging.warn("Processing as HTTP request")
return app(event,context) # Process via Chalice
elif 'detail-type' in event and event['detail-type']=='Scheduled Event':
CronHandler(event=event,context=context).execute()
elif 'Records' in event and len(event['Records'])>0 and 'kinesis' in event['Records'][0]:
BatchHandler(event=event,context=context).execute()
else:
raise BadRequestError('Currently unhandled event: {}'.format(event))
Then I configure Lambda to run app.command_router instead of app.app - This way, I can use the same function for http and batch processing (I use a kinesis stream as a batch processing queue). Just thought it might interest you!
Chris