Skip to content

Attempting to get bun to run on AWS Lambda

Notifications You must be signed in to change notification settings

mishchenkoy/bun-aws-lambda

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Outdated experiment

Use Bun's official custom AWS Lambda runtime layer

This repository is an outdated experiment superceded by https://github.com/oven-sh/bun/tree/main/packages/bun-lambda.


Original readme

This is a hacky attempt to get Bun to run on AWS Lambda. Don't know yet if it will be officially supported in the future. I'm just trying things.

./lambda.ts has the code necessary to respond to incoming requests in an AWS Lambda instance.

./function.js runs the user's code. It is expected that the user's code export default a fetch function like so:

export default {
  fetch(req) {
    return new Response("my response");
  },
};

In releases, you'll find a fully static build of Bun for Linux x64. This works around gnu libc incompatibilities with Lambda, but it statically links glibc which is a big no-no for several reasons (DNS resolution may not work, for example). That's what makes this, at the very best, a proof of concept and not something that should be used in production.

To deploy, zip up this folder along with the special bun binary and upload it to Lambda.

aws lambda create-function \
            --zip-file fileb://deployment.zip --handler function.handler --runtime provided \
            --role $MY_ARN_ROLE \
            --function-name $MY_FUNCTION_NAME

About

Attempting to get bun to run on AWS Lambda

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 92.2%
  • JavaScript 7.2%
  • Shell 0.6%