Before continuing, make sure you have:
- A Bun application ready for deployment
- An AWS account
- AWS CLI installed and configured
- Docker installed
Create a Dockerfile
The AWS Lambda Web Adapter bridges Lambda’s event-based invocation model with a standard HTTP server. Create a Also create a
Dockerfile in your project root:Dockerfile
Adjust the
CMD to match your application’s entry point. If you have a start script in package.json, you can use CMD ["bun", "run", "start"] instead..dockerignore to keep the image small:.dockerignore
Write a Bun HTTP server
Your server must listen on the port defined by the
PORT environment variable (Lambda sets this to 8080):index.ts
Build the Docker image
Build the image targeting the
linux/amd64 platform, which Lambda requires. The --provenance=false flag avoids a known ECR compatibility issue.Create an ECR repository
Create an Amazon Elastic Container Registry (ECR) repository to host the image, and export its URI:
If you use IAM Identity Center (SSO), append
--profile <your-profile> to every AWS CLI command.Create an AWS Lambda function
In the AWS Console, navigate to Lambda → Create function → Container image.
- Give the function a name (e.g.,
my-bun-function). - Under Container image URI, click Browse images and select the image you just pushed, choosing the
latesttag.
Configure a public URL
To expose the function over HTTPS without an API Gateway:
- Open Additional configurations → Networking → Function URL.
- Set Auth type to NONE and click Enable.
- Click Create function.
Environment variables
Set environment variables in the Lambda console under Configuration → Environment variables, or via the AWS CLI:process.env or Bun.env: