Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 27, 2026·3 min de lecture

AWS Chalice — Serverless Python Microframework for AWS Lambda

Chalice is a Python microframework by AWS for building serverless applications on AWS Lambda and API Gateway. It provides a Flask-like API for defining routes and event handlers that deploy automatically to AWS with a single command.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
AWS Chalice Serverless
Commande d'installation directe
npx -y tokrepo@latest install 50e31e7b-5a0a-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

AWS Chalice is a framework for writing serverless Python applications that run on AWS Lambda. It provides a decorator-based API similar to Flask for defining REST endpoints, scheduled tasks, and event handlers. Chalice handles the packaging, IAM policy generation, and deployment to AWS automatically.

What Chalice Does

  • Defines REST API routes with Python decorators that map to API Gateway endpoints
  • Automatically generates IAM policies based on the AWS services your code accesses
  • Packages and deploys Lambda functions with a single chalice deploy command
  • Supports event sources including S3, SQS, SNS, CloudWatch Events, and WebSockets
  • Provides local testing with chalice local for rapid development without deploying

Architecture Overview

Chalice analyzes your Python code to determine which AWS services you use and automatically generates the minimum IAM policy required. During deployment, it creates a Lambda function with your application code, sets up API Gateway routes, and configures event source mappings. The runtime routes incoming requests to the correct handler based on the URL path and HTTP method. Chalice uses AWS SAM or Terraform under the hood for infrastructure management.

Self-Hosting & Configuration

  • Requires Python 3.8+ and AWS credentials configured via aws configure or environment variables
  • Project configuration lives in .chalice/config.json for stage-specific settings
  • Set environment variables, memory size, timeout, and Lambda layers per deployment stage
  • Use chalice package to export a SAM or Terraform template for CI/CD pipelines
  • Manage dependencies in requirements.txt; Chalice bundles them into the deployment package

Key Features

  • Flask-like decorator syntax makes serverless development feel familiar to Python web developers
  • Automatic IAM policy generation eliminates manual permission configuration
  • Local development server for testing routes without deploying to AWS
  • Built-in support for WebSocket APIs, scheduled events, and pure Lambda functions
  • Terraform and SAM export for integration with existing infrastructure-as-code workflows

Comparison with Similar Tools

  • Serverless Framework — language-agnostic with YAML configuration; more flexible but more verbose for Python
  • AWS SAM — lower-level; gives more control over CloudFormation resources but requires more boilerplate
  • Zappa — deploys Django/Flask apps to Lambda; wraps existing WSGI apps rather than providing a native serverless API
  • FastAPI + Mangum — run FastAPI on Lambda via an adapter; good for existing FastAPI apps but not serverless-first
  • SST — TypeScript-first with broader AWS construct support; better for teams already using TypeScript

FAQ

Q: Can I use Chalice with an existing Flask or Django app? A: Chalice is its own framework, not a wrapper. For existing apps, consider Zappa or Mangum instead.

Q: How does automatic IAM policy generation work? A: Chalice uses static analysis to detect boto3 calls in your code and generates a policy with only the permissions those calls require.

Q: Does Chalice support container-based Lambda functions? A: Chalice primarily targets zip-based Lambda deployments. For container images, use SAM or CDK directly.

Q: Can I deploy to multiple AWS accounts or regions? A: Yes. Use stage-specific configuration in .chalice/config.json to target different accounts and regions per stage.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires