Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An OCaml custom runtime for AWS Lambda and Vercel

License

NotificationsYou must be signed in to change notification settings

anmonteiro/aws-lambda-ocaml-runtime

Repository files navigation

This package provides acustomruntime forAWS Lambda.

Installation

This repository provides two libraries:

  • lambda-runtime provides a runtime and API forAWS Lambda andAPI Gateway.
  • thevercel library depends onlambda-runtime and provides an interface totheVercel service that resembles a request / responseexchange.

The libraries in this repo are released to the OPAM package registry.

You can depend on them via:

  1. esy:esy add @opam/lambda-runtime and / oresy add @opam/vercel
  2. OPAM:opam install lambda-runtime vercel.

Example function

See theexamples folder.

Deploying

Note: Based on the instructions in thisblogpost andthe Rust custom runtimerepository

For a custom runtime, AWS Lambda looks for an executable calledbootstrap inthe deployment package zip. Rename the generatedbasic executable tobootstrap and add it to a zip archive.

The Dockerfile (in conjunction with thebuild.sh script) in thisrepo does just that. It builds a static binary calledbootstrap and drops itin the target directory.

$ ./build.sh&& zip -j ocaml.zip bootstrap

Now that we have a deployment package (ocaml.zip), we can use theAWSCLI to create a new Lambda function. Make sure toreplace the execution role with an existing role in your account!

$ aws lambda create-function --function-name OCamlTest \  --handler doesnt.matter \  --zip-file file://./ocaml.zip \  --runtime provided \  --role arn:aws:iam::XXXXXXXXXXXXX:role/your_lambda_execution_role \  --tracing-config Mode=Active

You can now test the function using the AWS CLI or the AWS Lambda console

$ aws lambda invoke --function-name OCamlTest \  --payload'{"firstName": "world"}' \  output.json$ cat output.json# Prints: {"message":"Hello, world!"}

Copyright & License

Copyright © 2018 António Nuno Monteiro

Distributed under the 3-clause BSD License (seeLICENSE).


[8]ページ先頭

©2009-2025 Movatter.jp