Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Jarred-Sumner/bun-aws-lambda
Attempting to get bun to run on AWS Lambda
https://github.com/Jarred-Sumner/bun-aws-lambda
Last synced: 3 months ago
JSON representation
Attempting to get bun to run on AWS Lambda
- Host: GitHub
- URL: https://github.com/Jarred-Sumner/bun-aws-lambda
- Owner: Jarred-Sumner
- Archived: true
- Created: 2022-09-18T12:06:50.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-25T06:38:57.000Z (over 1 year ago)
- Last Synced: 2024-05-11T15:35:36.749Z (6 months ago)
- Language: TypeScript
- Homepage:
- Size: 3.91 KB
- Stars: 58
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-bun - bun-aws-lambda - Hacky attempt to get bun to run on AWS Lambda (Extensions / Utilities)
README
# Outdated experiment
[**Use Bun's official custom AWS Lambda runtime layer**](https://github.com/oven-sh/bun/tree/main/packages/bun-lambda)
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](./lambda.ts) has the code necessary to respond to incoming requests in an AWS Lambda instance.
[./function.js](./function.js) runs the user's code. It is expected that the user's code `export default` a `fetch` function like so:
```js
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.
```bash
aws lambda create-function \
--zip-file fileb://deployment.zip --handler function.handler --runtime provided \
--role $MY_ARN_ROLE \
--function-name $MY_FUNCTION_NAME
```