chalice 1.32.0


pip install chalice

  Latest version

Released: May 29, 2025

Project Links

Meta
Author: James Saryerwinnie

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers

License
  • OSI Approved :: Apache Software License

Natural Language
  • English

Programming Language
  • Python :: 3
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
Gitter Documentation Status Chalice Logo

Chalice is a framework for writing serverless apps in python. It allows you to quickly create and deploy applications that use AWS Lambda. It provides:

  • A command line tool for creating, deploying, and managing your app

  • A decorator based API for integrating with Amazon API Gateway, Amazon S3, Amazon SNS, Amazon SQS, and other AWS services.

  • Automatic IAM policy generation

You can create Rest APIs:

from chalice import Chalice

app = Chalice(app_name="helloworld")

@app.route("/")
def index():
    return {"hello": "world"}

Tasks that run on a periodic basis:

from chalice import Chalice, Rate

app = Chalice(app_name="helloworld")

# Automatically runs every 5 minutes
@app.schedule(Rate(5, unit=Rate.MINUTES))
def periodic_task(event):
    return {"hello": "world"}

You can connect a lambda function to an S3 event:

from chalice import Chalice

app = Chalice(app_name="helloworld")

# Whenever an object is uploaded to 'mybucket'
# this lambda function will be invoked.

@app.on_s3_event(bucket='mybucket')
def handler(event):
    print("Object uploaded for bucket: %s, key: %s"
          % (event.bucket, event.key))

As well as an SQS queue:

from chalice import Chalice

app = Chalice(app_name="helloworld")

# Invoke this lambda function whenever a message
# is sent to the ``my-queue-name`` SQS queue.

@app.on_sqs_message(queue='my-queue-name')
def handler(event):
    for record in event:
        print("Message body: %s" % record.body)

And several other AWS resources.

Once you’ve written your code, you just run chalice deploy and Chalice takes care of deploying your app.

$ chalice deploy
...
https://endpoint/dev

$ curl https://endpoint/api
{"hello": "world"}

Up and running in less than 30 seconds. Give this project a try and share your feedback with us here on Github.

The documentation is available here.

Quickstart

In this tutorial, you’ll use the chalice command line utility to create and deploy a basic REST API. This quickstart uses Python 3.9, but AWS Chalice supports all versions of python supported by AWS Lambda, which includes Python 3.9 through python 3.13.

To install Chalice, we’ll first create and activate a virtual environment in python3.9:

$ python3 --version
Python 3.9.22
$ python3 -m venv venv39
$ . venv39/bin/activate

Next we’ll install Chalice using pip:

$ python3 -m pip install chalice

You can verify you have chalice installed by running:

$ chalice --help
Usage: chalice [OPTIONS] COMMAND [ARGS]...
...

Credentials

Before you can deploy an application, be sure you have credentials configured. If you have previously configured your machine to run boto3 (the AWS SDK for Python) or the AWS CLI then you can skip this section.

If this is your first time configuring credentials for AWS you can follow these steps to quickly get started:

$ mkdir ~/.aws
$ cat >> ~/.aws/config
[default]
aws_access_key_id=YOUR_ACCESS_KEY_HERE
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
region=YOUR_REGION (such as us-west-2, us-west-1, etc)

If you want more information on all the supported methods for configuring credentials, see the boto3 docs.

Creating Your Project

The next thing we’ll do is use the chalice command to create a new project:

$ chalice new-project helloworld

This will create a helloworld directory. Cd into this directory. You’ll see several files have been created for you:

$ cd helloworld
$ ls -la
drwxr-xr-x   .chalice
-rw-r--r--   app.py
-rw-r--r--   requirements.txt

You can ignore the .chalice directory for now, the two main files we’ll focus on is app.py and requirements.txt.

Let’s take a look at the app.py file:

from chalice import Chalice

app = Chalice(app_name='helloworld')


@app.route('/')
def index():
    return {'hello': 'world'}

The new-project command created a sample app that defines a single view, /, that when called will return the JSON body {"hello": "world"}.

Deploying

Let’s deploy this app. Make sure you’re in the helloworld directory and run chalice deploy:

$ chalice deploy
Creating deployment package.
Creating IAM role: helloworld-dev
Creating lambda function: helloworld-dev
Creating Rest API
Resources deployed:
  - Lambda ARN: arn:aws:lambda:us-west-2:12345:function:helloworld-dev
  - Rest API URL: https://abcd.execute-api.us-west-2.amazonaws.com/api/

You now have an API up and running using API Gateway and Lambda:

$ curl https://qxea58oupc.execute-api.us-west-2.amazonaws.com/api/
{"hello": "world"}

Try making a change to the returned dictionary from the index() function. You can then redeploy your changes by running chalice deploy.

Next Steps

You’ve now created your first app using chalice. You can make modifications to your app.py file and rerun chalice deploy to redeploy your changes.

At this point, there are several next steps you can take.

  • Tutorials - Choose from among several guided tutorials that will give you step-by-step examples of various features of Chalice.

  • Topics - Deep dive into documentation on specific areas of Chalice. This contains more detailed documentation than the tutorials.

  • API Reference - Low level reference documentation on all the classes and methods that are part of the public API of Chalice.

If you’re done experimenting with Chalice and you’d like to cleanup, you can use the chalice delete command, and Chalice will delete all the resources it created when running the chalice deploy command.

$ chalice delete
Deleting Rest API: abcd4kwyl4
Deleting function aws:arn:lambda:region:123456789:helloworld-dev
Deleting IAM Role helloworld-dev

Feedback

We’d also love to hear from you. Please create any Github issues for additional features you’d like to see over at https://github.com/aws/chalice/issues. You can also chat with us on gitter: https://gitter.im/awslabs/chalice

1.32.0 May 29, 2025
1.31.4 Feb 05, 2025
1.31.3 Dec 12, 2024
1.31.2 Jun 10, 2024
1.31.1 May 29, 2024
1.31.0 Feb 27, 2024
1.30.0 Dec 15, 2023
1.29.0 Jun 05, 2023
1.28.0 Mar 09, 2023
1.27.3 Sep 01, 2022
1.27.2 Aug 23, 2022
1.27.1 Jun 01, 2022
1.27.0 Apr 19, 2022
1.26.6 Feb 08, 2022
1.26.5 Jan 19, 2022
1.26.4 Jan 05, 2022
1.26.3 Jan 03, 2022
1.26.2 Nov 03, 2021
1.26.1 Oct 15, 2021
1.26.0 Sep 29, 2021
1.25.0 Sep 20, 2021
1.24.2 Aug 18, 2021
1.24.1 Aug 03, 2021
1.24.0 Jul 16, 2021
1.23.0 May 13, 2021
1.22.4 Apr 26, 2021
1.22.3 Mar 23, 2021
1.22.2 Mar 08, 2021
1.22.1 Feb 01, 2021
1.22.0 Jan 21, 2021
1.21.9 Jan 15, 2021
1.21.8 Jan 07, 2021
1.21.7 Dec 17, 2020
1.21.6 Dec 11, 2020
1.21.5 Dec 04, 2020
1.21.4 Oct 30, 2020
1.21.3 Oct 26, 2020
1.21.2 Oct 19, 2020
1.21.1 Oct 08, 2020
1.21.0 Oct 02, 2020
1.20.1 Sep 28, 2020
1.20.0 Sep 16, 2020
1.19.0 Sep 03, 2020
1.18.1 Aug 25, 2020
1.18.0 Aug 19, 2020
1.17.0 Aug 05, 2020
1.16.0 Jul 21, 2020
1.15.1 Jun 16, 2020
1.15.0 Jun 15, 2020
1.14.1 May 12, 2020
1.14.0 Apr 22, 2020
1.13.1 Apr 06, 2020
1.13.0 Mar 02, 2020
1.12.0 Oct 15, 2019
1.11.1 Sep 17, 2019
1.11.0 Aug 28, 2019
1.10.0 Aug 07, 2019
1.9.1 Jul 09, 2019
1.9.0 Jun 17, 2019
1.8.0 Apr 03, 2019
1.7.0 Feb 05, 2019
1.6.2 Jan 02, 2019
1.6.1 Nov 01, 2018
1.6.0 Jul 20, 2018
1.5.0 Jul 10, 2018
1.4.0 Jul 10, 2018
1.3.0 May 22, 2018
1.2.3 May 08, 2018
1.2.2 Apr 13, 2018
1.2.1 Apr 12, 2018
1.2.0 Apr 06, 2018
1.1.1 Feb 27, 2018
1.1.0 Dec 06, 2017
1.0.4 Oct 25, 2017
1.0.3 Sep 27, 2017
1.0.2 Sep 05, 2017
1.0.1 Aug 16, 2017
1.0.0 Jul 31, 2017
1.0.0b2 Jul 26, 2017
1.0.0b1 Jul 05, 2017
0.10.1 Jun 26, 2017
0.10.0 Jun 22, 2017
0.9.0 May 31, 2017
0.8.2 May 08, 2017
0.8.1 May 02, 2017
0.8.0 Apr 18, 2017
0.7.0 Apr 05, 2017
0.6.0 Feb 23, 2017
0.5.1 Jan 05, 2017
0.5.0 Nov 28, 2016
0.4.0 Nov 01, 2016
0.3.0 Oct 13, 2016
0.2.0 Sep 28, 2016
0.1.0 Aug 04, 2016
0.0.1 Jul 11, 2016

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
click (<9.0,>=7)
botocore (<2.0.0,>=1.14.0)
six (<2.0.0,>=1.10.0)
pip (<25.1,>=9)
jmespath (<2.0.0,>=0.9.3)
pyyaml (<7.0.0,>=5.3.1)
inquirer (<4.0.0,>=3.0.0)
wheel
setuptools