cargo-lambda
raw JSON → 1.9.1 verified Fri May 01 auth: no python
A Cargo subcommand for building, deploying, and testing AWS Lambda functions written in Rust. Current version 1.9.1, released on 2025-11-01. Active development with periodic releases.
pip install cargo-lambda Common errors
error error: could not find `Cargo.toml` in `/path/to/some/dir` or any parent directory ↓
cause Running cargo-lambda outside a Rust project with a Cargo.toml.
fix
Run 'cargo lambda' from the root of your Rust project (where Cargo.toml is located).
error error: failed to run custom build command for `openssl-sys v0.9.x` ↓
cause Missing OpenSSL development headers when cross-compiling for Lambda with --features openssl.
fix
Install OpenSSL development packages: 'sudo apt install libssl-dev' on Debian/Ubuntu or 'brew install openssl' on macOS, then rebuild.
Warnings
gotcha cargo-lambda requires Zig for cross-compilation to AWS Lambda's Amazon Linux 2 environment. Without Zig, builds may fail or produce incompatible binaries. ↓
fix Install Zig (e.g., via brew install zig or download from ziglang.org) and ensure it's in PATH.
breaking In v1.8.0, the '--iam-role' flag for 'cargo lambda deploy' changed behavior: it now only sets the role on initial creation, not on subsequent updates. To update an existing function's role, use 'cargo lambda update --iam-role'. ↓
fix Use 'cargo lambda update --iam-role arn:aws:iam::...' instead of 'deploy' for existing functions.
Imports
- cargo_lambda
import cargo_lambda
Quickstart
# Build a Lambda function
!cargo lambda build --release
# Deploy to AWS
!cargo lambda deploy --iam-role arn:aws:iam::123456789012:role/lambda-role
# Invoke locally
!cargo lambda invoke --data-file payload.json