bunric provides an AWS Lambda Runtime Interface Client (RIC) for the Bun JavaScript runtime. It's a migration of the original Node.js-based AWS Lambda Runtime Interface Client to use Bun instead, offering improved performance and faster cold start times.
Recommended way is to use the optimized bunric image.
In case you want to use custom image, you e.g. refer to the Dockerfile regarding how to build such.
- NPM Package: @aawa/bunric
- Git Repository: nakamorichi/bunric
- Docker Hub: nakamorichi/bunric
- Pure JavaScript/TypeScript Implementation: No native C++ dependencies, uses
Bun.fetch
for all HTTP communication - Improved Performance: Leverages Bun's fast startup and execution for better Lambda cold start times
- Full Lambda Runtime API Compliance: Complete implementation of AWS Lambda Runtime Interface specification
- ES Modules Support: Built with modern ES modules and TypeScript
- Streaming Response Support: Handles both standard and streaming Lambda responses
- Multi-tenant Logging: Supports tenant ID logging for multi-tenant applications
- Production Ready: Comprehensive error handling, structured logging, and robust testing
- No Native Dependencies: Eliminates C++ native addons used in the original Node.js RIC
- Bun.fetch Integration: Uses Bun's optimized HTTP client for all Lambda Runtime API communication
- Simplified Build Process: No need for node-gyp or C++ compilation
- Fast Cold Starts: Leverages Bun's rapid startup time
- Efficient HTTP Communication: Uses Bun's native fetch implementation
- ES Modules: Modern module system for better performance
- TypeScript Support: Full TypeScript support with type checking
- Streaming Responses: Supports Lambda streaming response mode
- Complete implementation of AWS Lambda Runtime Interface specification
- Support for all Lambda lifecycle events (init, invocation, error handling)
- Multi-tenant logging with tenant ID support
- Proper error formatting and reporting
├── src/ # Source code for the RIC implementation
│ ├── pkg/ # Core RIC packages
│ │ ├── Runtime.ts # Main runtime orchestrator
│ │ ├── RAPIDClient.ts # Lambda Runtime API client
│ │ ├── UserFunction.ts# Handler loading and execution
│ │ └── ... # Other core modules
│ ├── bin/ # RIC executable entrypoint
│ └── scripts/ # Build and utility scripts
├── dist/ # Compiled RIC package (created during build)
├── examples/ # Example Lambda functions
│ └── simple-function/ # Basic example with Dockerfile
├── test/ # Comprehensive test suite
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
├── entrypoint.js # Docker entrypoint script
└── Dockerfile # Base image for Lambda functions
- Bun 1.0.0 or higher
- Docker for building and running containers
- TypeScript for development (included in devDependencies)
# Clone the repository
git clone https://github.com/nakamorichi/bunric.git
cd bunric
# Install dependencies
bun install
# Run type checking
bun run typecheck
# Run tests
bun run tests
# Build the package
bun run build
# Build Docker image
docker build -t nakamorichi/bunric:latest .
# Run unit tests
bun run tests
# Run integration tests
make test-integ
# Run smoke tests
make test-smoke
DEBUG=1
- Enable debug logging in the entrypoint scriptLAMBDA_TASK_ROOT
- Directory where Lambda function code is located (defaults to/var/task
)AWS_LAMBDA_RUNTIME_API
- Lambda Runtime Interface API endpoint (set by AWS Lambda)AWS_LAMBDA_FUNCTION_NAME
- Lambda function name (set by AWS Lambda)AWS_LAMBDA_FUNCTION_VERSION
- Lambda function version (set by AWS Lambda)
If you're migrating from the Node.js-based AWS Lambda Runtime Interface Client, see MIGRATION.md for detailed guidance including:
- Key differences between Node.js and Bun RIC
- Step-by-step migration instructions
- Common issues and solutions
- Performance considerations
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Make your changes
- Run the verification steps:
bun run typecheck # TypeScript compilation bun run lint # Linting bun run tests # All tests must pass bun run build # Build verification
- Submit a pull request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.