Skip to content

Boilerplate for using Rust on Amazon AWS Lambda

Notifications You must be signed in to change notification settings

DimensionDev/aws_lambda_rust_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

Boilerplate for using Rust on Amazon AWS Lambda

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published