Add AWS Lambda deployment support (Zappa-like experience) #1699
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds native AWS Lambda deployment support to Loco, aiming to provide a simple way to deploy applications to AWS Lambda with just a single command—much like Zappa does for Python projects. It's my first Pull Request here, so I'm really excited but also a bit nervous; I'm not entirely sure if I should be opening this yet or if it's ready for review. If there's anything I need to adjust, add, or fix, please just let me know—I'm happy to iterate!
Motivation
While Loco already supports Docker and Shuttle deployments, AWS Lambda support opens the door to the massive AWS ecosystem.
The implementation is inspired by Zappa, the popular Python framework for serverless deployment. Like Zappa, this feature:
CLI Commands
Deploy to AWS Lambda
cargo loco lambda deployBuild only (dry run)
cargo loco lambda deploy --dry-runInvoke the deployed function
View CloudWatch logs
The handler uses the
lambda_httpcrate to adapt HTTP requests from API Gateway or Lambda Function URLs to Axum-compatible requests, which Loco handles natively.Dependencies
This feature requires Cargo Lambda to be installed:
cargo install cargo-lambdaNo new Rust dependencies are added to Loco itself—the Lambda runtime dependencies are only added to the user's project during the build process.
Testing
Tested with a fresh Loco API project:
cargo loco newconfig/development.yamlcargo loco lambda deploycargo loco lambda invokecargo loco lambda logsRelated