Skip to content

A comparison between AWS Chalice and AWS SAM

AWS Chalice is a microframework for writing serverless apps in Python.

The following table provides a mapping between AWS SAM and AWS Chalice commands:

Chalice

Main options

Notes

SAM equivalent

chalice new-project

initialize an "hello world" sample project at the dev stage

sam init --name

chalice deploy

--no-autogen-policy to avoid auto policy generation, requires a source policy file .chalice/policy-.json
--stage to set a different deployment stage (dev by default)

Chalice automatically builds apps, storing the build results in .chalice/deployments/

sam build && sam deploy

chalice local

--port=XXXX to redirect local hosting on a specific port

locally run the app (by default on port 8000)

partially covered by sam local invoke

chalice invoke --name

invoke a Lambda function

partially covered by sam local invoke

chalice gen-policy

redirect to stdout the auto-generated AWS policy for the defined app (useful as a starting template for .chalice/policy-.json)

chalice delete

delete the deployed app

The following sample is the Chalice implementation equivalent of SAM project discussed here.

chalice-app/
│
├── .chalice/
│   ├── deployed/
│   │   └── <stage_name>.json
│   ├── deployments/
│   ├── policy-<stage_name>.json
│   └── config.json
│
├── chalicelib/
│   ├── __init__.py
│   └── custom_script.py
│
├── app.py
│
└── requirements.txt

where app.py contains (possibly) all the Lambda handlers, each one decorated with @app.lambda_function(name='my_lambda_name'), needed to let Chalice treat them as pure Lambda functions.