Skip to main content

Crate armature_lambda

Crate armature_lambda 

Source
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 deploy

Re-exports§

pub use lambda_http;
pub use lambda_runtime;
pub use async_trait;

Macros§

impl_lambda_handler
Implement RequestHandler for a type that already exposes an inherent async handle_request method.

Structs§

LambdaConfig
Lambda runtime configuration.
LambdaRequest
Wrapper for Lambda HTTP requests.
LambdaResponse
Lambda HTTP response.
LambdaRuntime
Lambda runtime driver.
RequestContext
Request context from API Gateway.

Enums§

LambdaError
Lambda runtime errors.

Traits§

RequestHandler
The contract LambdaRuntime drives.

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.