lambda-simulator
High-fidelity AWS Lambda Runtime API simulator for testing Lambda runtimes and extensions locally.

The simulator reproduces real Lambda behaviour including process freeze/thaw using SIGSTOP/SIGCONT signals. Run the demo yourself:
Overview
This crate provides a simulator that implements the AWS Lambda Runtime API, Extensions API, and Telemetry API, allowing you to test Lambda runtimes and extensions without deploying to AWS. It's particularly useful for:
- Testing Lambda extensions (OpenTelemetry collectors, custom extensions)
- Developing custom Lambda runtimes
- Integration testing Lambda handlers with extensions
- Validating telemetry pipelines locally
Features
- Runtime API - Full implementation of the Lambda Runtime Interface (
/runtime/invocation/next, response/error endpoints) - Extensions API - Extension registration, lifecycle events (INVOKE, SHUTDOWN)
- Telemetry API - Platform telemetry subscription and event delivery
- Process Freezing - Simulates Lambda's freeze/thaw behaviour using SIGSTOP/SIGCONT (Unix only)
- Event-Driven Testing - Efficient wait helpers that eliminate flaky sleep-based synchronisation
- In-Memory Telemetry Capture - Capture and assert on telemetry events without HTTP servers
Installation
[]
= "0.1.0"
Minimum Supported Rust Version (MSRV): 1.91.1
Quick Start
use ;
use json;
async
Testing Lambda Runtimes
The simulator provides efficient, event-driven wait helpers:
use ;
use json;
use Duration;
async
Testing Extensions
use Simulator;
use Duration;
async
Telemetry Capture
Capture telemetry events in memory for assertions:
use Simulator;
use json;
async
Process Freezing (Unix Only)
Simulate Lambda's freeze/thaw behaviour:
use ;
let simulator = builder
.freeze_mode
.build
.await?;
// Register PIDs to freeze between invocations
simulator.register_pid_for_freeze.await;
// Processes are frozen after invocation completes
// and unfrozen when the next invocation arrives
API Coverage
Runtime API
| Endpoint | Status |
|---|---|
GET /runtime/invocation/next |
✅ |
POST /runtime/invocation/{id}/response |
✅ |
POST /runtime/invocation/{id}/error |
✅ |
POST /runtime/init/error |
✅ |
Extensions API
| Endpoint | Status |
|---|---|
POST /extension/register |
✅ |
GET /extension/event/next |
✅ |
POST /extension/init/error |
✅ |
POST /extension/exit/error |
✅ |
Telemetry API
| Endpoint | Status |
|---|---|
PUT /telemetry |
✅ |
Platform Support
| Feature | Linux | macOS | Windows |
|---|---|---|---|
| Runtime API | ✅ | ✅ | ✅ |
| Extensions API | ✅ | ✅ | ✅ |
| Telemetry API | ✅ | ✅ | ✅ |
| Process Freezing | ✅ | ✅ | ❌ |
Process freezing uses POSIX signals (SIGSTOP/SIGCONT) and is not available on Windows.
Current Limitations
This simulator is designed for testing and development. Some AWS Lambda behaviours are not yet fully simulated:
- Timeout enforcement - The
Lambda-Runtime-Deadline-Msheader is set correctly, but invocations are not automatically terminated when they exceed their timeout - Memory limits - Memory usage is not enforced or accurately reported
- Concurrent invocations - The simulator processes invocations sequentially
- SnapStart - Restore events and snapshot-based initialisation are not simulated
These limitations don't affect most testing scenarios, but be aware of them when validating timeout handling or resource limits.
Licence
MIT