Expand description
§Armature Lambda
AWS Lambda runtime adapter for Armature applications.
This crate runs an HTTP handler on AWS Lambda behind API Gateway, ALB, or
Lambda Function URLs, translating the incoming event into a
LambdaRequest and the handler’s LambdaResponse back out.
§What this crate does and does not do
LambdaRuntime drives any type implementing RequestHandler, which is
stated in this crate’s own LambdaRequest/LambdaResponse types. It
does not convert to or from armature_core::HttpRequest /
HttpResponse, and there is no blanket implementation for an Armature
Application — wiring one up is the application author’s job, most easily
via impl_lambda_handler! (see its documentation for the exact shape it
expects).
§Quick Start
ⓘ
use armature_lambda::{LambdaRequest, LambdaResponse, LambdaRuntime};
#[tokio::main]
async fn main() -> Result<(), lambda_runtime::Error> {
// Initialize tracing for CloudWatch
armature_lambda::init_tracing();
let handler = |req: LambdaRequest| async move {
LambdaResponse::ok(format!("Hello from {}!", req.path))
};
LambdaRuntime::new(handler).run().await
}§Deployment
Build for Lambda with:
# Install cargo-lambda
cargo install cargo-lambda
# Build for Lambda
cargo lambda build --release
# Deploy
cargo lambda deployRe-exports§
pub use lambda_http;pub use lambda_runtime;pub use async_trait;
Macros§
- impl_
lambda_ handler - Implement
RequestHandlerfor a type that already exposes an inherent asynchandle_requestmethod.
Structs§
- Lambda
Config - Lambda runtime configuration.
- Lambda
Request - Wrapper for Lambda HTTP requests.
- Lambda
Response - Lambda HTTP response.
- Lambda
Runtime - Lambda runtime driver.
- Request
Context - Request context from API Gateway.
Enums§
- Lambda
Error - Lambda runtime errors.
Traits§
- Request
Handler - The contract
LambdaRuntimedrives.
Functions§
- init_
tracing - Initialize tracing for Lambda/CloudWatch.
- init_
tracing_ with_ level - Initialize tracing with a custom log level.
Type Aliases§
- Result
- Result type for Lambda operations.