An AWS Lambda runtime for Bun
This exposes the same API as the Node.js runtime. If you are looking how to handle different events, you can refer to AWS documentation. The only difference is we do not support callbacks and the following properties on the context object:
context.callbackWaitsForEmptyEventLoop
context.done
context.fail
context.succeed
Add these secrets to the repository. They must have access to publish lambda layers:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
- Clone or fork this repository
- Go to the Actions tab
- Select the action name
Publish Layer
- Run the workflow with your desired parameters
import type {
APIGatewayProxyEventV2,
APIGatewayProxyResultV2,
Context,
} from "aws-lambda";
export default {
handler(
event: APIGatewayProxyEventV2,
context: Context
): APIGatewayProxyResultV2 {
return {
statusCode: 200,
headers: {
"Content-Type": "text/html",
},
body: "Hello from Buntime!",
};
},
};
An example can be found in <./examples/local.ts
>. In this example, it imports the handler from <./examples/handler.ts
> and calls it in a simple HTTP server.
We dynamically set the trace id environment variable so you MUST access it using process.env._X_AMZN_TRACE_ID
. Bun.env._X_AMZN_TRACE_ID
will not work.