[][src]Crate lando

Lando provides building blocks for serverless HTTP Rust applications deployable on AWS Lambda.

Specifically, lando exposes API Gateway proxy events as standard Rust http types with API Gateway modeled Bodies. For convenience, lando re-exports http::Request and http::Response.

AWS Lambda is a ✨ fully managed ✨ compute service allowing you to run code without thinking about servers. AWS will provide monitoring metrics and scaling out of the box for you.

Lando exports Rust functions as native CPython modules making it possible to embed handlers within AWS' Python3.6 runtime.


Add lando to your Cargo.toml

lando = "0.2"

Within your application's source, use lando's macros.

extern crate lando;

Write your function using the gateway! macro. See it's documentation for more examples.

gateway!(|_request, context| {
    println!("👋 cloudwatch logs, this is {}", context.function_name());
    // return a basic 200 response

Alternatively, you can also just attribute a bare handler fn with #[lando]

use lando::{Request, LambdaContext, IntoResponse, Result};

fn handler(
    _: Request,
    _: LambdaContext
) -> Result<impl IntoResponse> {

Packaging functions

Lando targets AWS Lambda's Python3.6 runtime. The gateway! macro does the all the integration for you, but cargo still needs to know what type of lib you are compiling. Cargo makes it easy to produce compatible binaries.

Simply add the following setting to your crate's Cargo.toml file.

crate-type = ["cdylib"]

💡 cdylib produces dynamic library embeddable in other languages. This and other link formats are described here

cargo build will then produce an AWS deploy-ready liblambda.so binary artifact on linux hosts. Package this file in a zip file and it's now deployable as an AWS Lambda function! Be sure to use the the Python 3.6 execution environment with the handler configured as lib{your_crate_name}.handler.

Because you're building a dynamic library, other libraries that you're dynamically linking against need to also be in the Lambda execution environment. The easiest way to achive this is by building in an environment similar to Lambda's. This Docker container faithfully reproduces the AWS Lambda Python 3.6 runtime.


pub extern crate http;
pub extern crate lando_attr;
pub use request::GatewayRequest;



API Gateway request types. Typically these are exposed via the request_context method provided by lando::RequestExt



A macro that exposes a Lambda function handler for AWS API gateway proxy event triggers.



Provides a view into the context object available to Lambda functions.


Represents an HTTP response


A read-only view into a map of string data



Representation of http request and response bodies as supported by API Gateway.


Payload deserialization errors



A conversion of self into a Response


Extentions for lando::Request structs that provide access to API gateway features

Type Definitions


A re-exported version of http::Request with a type parameter for body fixed to type lando::Body


Result type for gateway functions