WIP - extracted from production, still figuring out what else to add
My go-to patterns for Rust microservices on AWS Lambda. Got tired of copying the same boilerplate between services so I extracted what actually works.
- Cargo workspace - monorepo structure, common crate for shared stuff
- lambda_http - lighter than Axum/Actix for Lambda
- DynamoDB singleton - OnceCell pattern, no client recreation per request
- Dual-mode auth - dev tokens for local, Cognito JWT for prod
- Cursor pagination - base64 encoded LastEvaluatedKey, works out of the box
cargo check
cargo test
# or build for lambda
cargo lambda build --releaseβββ common/ # shared utilities
β βββ src/
β βββ auth.rs # dual-mode JWT
β βββ db.rs # dynamodb singleton
β βββ cors.rs
β βββ health.rs
β βββ pagination.rs
βββ services/
βββ example/ # copy this for new services
curl -H "Authorization: Bearer dev:matt@example.com:user" \
http://localhost:9000/itemsFormat: Bearer dev:<email>:<role>
- Copy
services/example/ - Add to workspace in root
Cargo.toml - Implement your handlers
Pairs well with solidjs-fe-template for admin portals.