lando 0.2.1

Rust http interface for AWS lambda API gateway events
lando-0.2.1 doesn't have any documentation.

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.

Usage

Add lando to your Cargo.toml

[dependencies]
lando = "0.2"

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

#[macro_use]
extern crate lando;
# fn main() { }

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

# #[macro_use] extern crate lando;

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

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

# #[macro_use] extern crate lando;
use lando::{Request, LambdaContext, IntoResponse, Result};

#[lando]
fn handler(
_: Request,
_: LambdaContext
) -> Result<impl IntoResponse> {
Ok(())
}

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.

[lib]
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.