See cross-rs/cross for installation guide.
In brief:
docker
should be prepared.cargo install cross
make lambda-build
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
make lambda-update
Refer to akrylysov/algnhsa -> Setting up API Gateway
chapter.
If needed, create a Stage
for this API.
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
}