|
| 1 | +--- |
| 2 | +title: Build Recipes |
| 3 | +description: Lambda function packaging recipes with Powertools for AWS |
| 4 | +--- |
| 5 | + |
| 6 | +<!-- markdownlint-disable MD043 MD013 --> |
| 7 | + |
| 8 | +As the Python ecosystem continues to evolve with new package managers, build tools, and dependency resolution strategies, choosing the right approach for Lambda deployments has become increasingly complex. Modern Python applications often involve compiled extensions, platform-specific dependencies, and sophisticated toolchains that require careful consideration for serverless environments. |
| 9 | + |
| 10 | +This guide provides practical recipes for packaging Lambda functions with Powertools for AWS Lambda (Python) using different build tools and dependency managers. |
| 11 | + |
| 12 | +## Key benefits |
| 13 | + |
| 14 | +* **Optimized packaging** - Reduce deployment package size and cold start times |
| 15 | +* **Dependency management** - Handle complex dependency trees efficiently |
| 16 | +* **Build reproducibility** - Consistent builds across environments |
| 17 | +* **Layer optimization** - Leverage Lambda Layers for better performance |
| 18 | +* **Multi-tool support** - Choose the right tool for your workflow |
| 19 | + |
| 20 | +## Terminology |
| 21 | + |
| 22 | +Understanding these key terms will help you navigate the build recipes more effectively: |
| 23 | + |
| 24 | +| Term | Definition | |
| 25 | +|------|------------| |
| 26 | +| **Deployment Package** | A ZIP archive or container image containing your Lambda function code and all its dependencies, ready for deployment to AWS Lambda | |
| 27 | +| **Lambda Layer** | A ZIP archive containing libraries, custom runtimes, or other function dependencies that can be shared across multiple Lambda functions | |
| 28 | +| **Build Tool** | Software that automates the process of compiling, packaging, and preparing your code for deployment (e.g., pip, poetry, uv, pants) | |
| 29 | +| **Dependency Manager** | Tool responsible for resolving, downloading, and managing external libraries your project depends on | |
| 30 | +| **Lock File** | A file that records the exact versions of all dependencies used in your project, ensuring reproducible builds (e.g., poetry.lock, uv.lock) | |
| 31 | +| **Cold Start** | The initialization time when AWS Lambda creates a new execution environment for your function, including loading your deployment package | |
| 32 | +| **SAM (Serverless Application Model)** | AWS framework for building serverless applications, providing templates and CLI tools for deploying Lambda functions and related resources | |
| 33 | +| **CDK (Cloud Development Kit)** | AWS framework for defining cloud infrastructure using familiar programming languages, enabling infrastructure as code for Lambda deployments | |
| 34 | + |
| 35 | +## Guide sections |
| 36 | + |
| 37 | +This guide is organized into focused sections to help you find exactly what you need: |
| 38 | + |
| 39 | +### 📚 Fundamentals |
| 40 | + |
| 41 | +* **[Getting started](getting-started.md)** - Prerequisites, tool selection, and basic setup |
| 42 | +* **[Cross-platform builds](cross-platform.md)** - Handle architecture differences and compiled dependencies |
| 43 | + |
| 44 | +### 🔧 Build tools |
| 45 | + |
| 46 | +* **[Build with pip](build-with-pip.md)** - Simple, universal package management |
| 47 | +* **[Build with Poetry](build-with-poetry.md)** - Modern dependency management with lock files |
| 48 | +* **[Build with uv](build-with-uv.md)** - Extremely fast Rust-based package manager |
| 49 | +* **[Build with SAM](build-with-sam.md)** - AWS Serverless Application Model integration |
| 50 | +* **[Build with CDK](build-with-cdk.md)** - Infrastructure as code with type safety |
| 51 | +* **[Build with Pants](build-with-pants.md)** - Advanced build system for monorepos |
| 52 | + |
| 53 | +### ⚡ Advanced topics |
| 54 | + |
| 55 | +* **[Performance optimization](performance-optimization.md)** - Reduce cold starts and package size |
| 56 | +* **[CI/CD integration](cicd-integration.md)** - Automate builds with GitHub Actions and CodeBuild |
| 57 | +* **[Troubleshooting](troubleshooting.md)** - Common issues and solutions |
0 commit comments