Skip to content

Latest commit

 

History

History
104 lines (80 loc) · 2.15 KB

README.org

File metadata and controls

104 lines (80 loc) · 2.15 KB

AWS Lambda template for Rust

How to use

Preparation

See cross-rs/cross for installation guide.

In brief:

  1. docker should be prepared.
  2. cargo install cross

Compile

make lambda-build

Create lambda function

Create a file named `lambda.mk` with these content:

# Modify with your choice.
function-name=my_function_name
# Create a role for this function runtime on AWS beforehead.
function-role=arn:aws:iam::xxxx

Then,

make lambda-create

Upload / Update function

make lambda-update

Create API Gateway

Refer to akrylysov/algnhsa -> Setting up API Gateway chapter.

If needed, create a Stage for this API.

[0/1] TODOs

Intergrate a “true” HTTP server w/ full router support

Since master branch of lambda_http::Request implements tower::Service trait, we should use something like this to dramatically decrease complexity of current code.

// Copied from https://github.com/awslabs/aws-lambda-rust-runtime/issues/404
use tower::Service;
use lambda_http::{Request, ServiceExt};

#[derive(Default)]
struct MyHandler;

//   vvvvvvvvvvvvvvvv HERE
impl Service<Request> for MyHandler {
    // skipped
}

#[tokio::main]
async fn main() -> Result<(), Error> {
    // Use lambda_http::run to wrap the Service
    lambda_http::run(MyHandler::default()).await
}