This sample demonstrates the AWS Chalice framework with LocalStack using chalice-local.
AWS Chalice is a Python serverless microframework for AWS. This sample shows a simple TODO REST API deployed to LocalStack using chalice-local.
Chalice App (app.py)
└── chalice-local deploy
└── API Gateway + Lambda (LocalStack)
└── REST API Endpoints
- LocalStack Pro
- Python 3.10+
- chalice and chalice-local
Install Chalice and chalice-local:
pip install chalice chalice-localOr with uv:
uv tool install chalice
uv tool install chalice-local| Method | Status | Notes |
|---|---|---|
| scripts | Supported | Uses chalice-local |
| terraform | Not applicable | Chalice has its own deployment |
| cloudformation | Not applicable | Chalice generates CloudFormation |
| cdk | Not applicable | Chalice has its own deployment |
cd samples/chalice-rest-api/python
# Deploy
./scripts/deploy.sh
# Or manually
chalice-local deploy
# Teardown
./scripts/teardown.sh
# Or manually
chalice-local delete# Run all tests
uv run pytest samples/chalice-rest-api/python/ -vTests will skip if chalice-local is not installed.
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
API info |
| GET | /health |
Health check |
| GET | /todo |
List all TODOs |
| GET | /todo/{id} |
Get TODO by ID |
| POST | /todo |
Add new TODO |
| PUT | /todo/{id} |
Replace TODO |
| POST | /todo/{id} |
Update TODO |
| DELETE | /todo/{id} |
Delete TODO |
| GET | /introspect |
Request details |
After deployment:
# Get API info
curl $API_URL/
# List TODOs
curl $API_URL/todo
# Add TODO
curl -X POST $API_URL/todo \
-H "Content-Type: application/json" \
-d '{"item": "New task"}'
# Get specific TODO
curl $API_URL/todo/1
# Health check
curl $API_URL/health- API Gateway REST API
- Lambda function(s) for each route
- IAM roles for Lambda execution
After deployment, the following variables are written to scripts/.env:
CHALICE_AVAILABLE: Whether chalice-local is installedDEPLOY_SUCCESS: Whether deployment succeededAPI_URL: The deployed API URL
chalice-rest-api/python/
├── app.py # Chalice application
├── .chalice/
│ └── config.json # Chalice configuration
├── scripts/
│ ├── deploy.sh
│ └── teardown.sh
└── test_chalice_api.py
Apache 2.0