Lambda-first hosting with Minimal API-inspired patterns β Familiar .NET ergonomics with handlers, DI, and middleware, purpose-built for AWS Lambda triggers.
MinimalLambda brings the clean, declarative style of ASP.NET Core Minimal APIs to AWS Lambda while staying grounded in Lambdaβs execution model. Use the same mental model (builder, DI, middleware, handler mapping) while leaning on Lambda-specific features like strongly-typed envelopes, lifecycle hooks, scoped invocations, and source generation.
- Familiar builder flow:
LambdaApplication.CreateBuilder()βBuild()βRunAsync() - .NET DI you already use:
builder.Services.AddScoped<IMyService, MyService>()with Lambda-safe lifetimes - Handler mapping, Lambda edition:
lambda.MapHandler(...)instead of crafting raw handlers - Middleware for cross-cutting concerns:
lambda.UseMiddleware(...)to wrap your pipeline - Lambda-first runtime: Lifecycle hooks, cancellation token management, and strongly typed envelope models for event triggers
Instead of writing boilerplate Lambda handlers, you keep familiar .NET patterns while the framework handles event envelopes, dependency injection, scoped lifetimes, middleware, and compile-time code generation for zero reflection overhead.
- Minimal API Pattern β Map handlers with
lambda.MapHandler(...)just likeapp.MapGet()in ASP.NET Core β clean, declarative, and intuitive - Dependency Injection β Constructor and parameter injection using
Microsoft.Extensions.DependencyInjectionwith proper scoped lifetimes per invocation - Middleware Pipeline β Familiar
Use()pattern for cross-cutting concerns like logging, validation, and error handling - Source Generated β Compile-time code generation for zero reflection overhead and optimal performance
- AOT Ready β Native AOT compilation support for fast cold starts
- Built-in Observability β OpenTelemetry integration for distributed tracing and metrics
- Type-Safe Envelopes β Strongly-typed event wrappers for SQS, SNS, API Gateway, Kinesis, and more
- Minimal Runtime Overhead β Lightweight abstraction layer built on the same foundation as ASP.NET Core
The framework is divided into multiple NuGet packages:
The core packages provide the fundamental hosting framework, abstractions, and observability support for building AWS Lambda functions.
| Package | NuGet | Downloads |
|---|---|---|
| MinimalLambda | ||
| MinimalLambda.Abstractions | ||
| MinimalLambda.OpenTelemetry | ||
| MinimalLambda.Testing |
Envelope packages provide specialized support for handling different AWS Lambda event sources, including SQS, SNS, API Gateway, Kinesis, and more.
Each package has detailed documentation in its own README file.
Install the NuGet package:
dotnet add package MinimalLambdaCreate a simple Lambda handler with dependency injection:
using MinimalLambda.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
// Configure and run
var builder = LambdaApplication.CreateBuilder();
builder.Services.AddScoped<IGreetingService, GreetingService>();
var lambda = builder.Build();
// Inject the service directly into the handler
lambda.MapHandler(([FromEvent] string input, IGreetingService greeting) => greeting.Greet(input));
await lambda.RunAsync();
// Define a service interface
public interface IGreetingService
{
string Greet(string name);
}
// Implement the service
public class GreetingService : IGreetingService
{
public string Greet(string name) => $"Hello {name}!";
}See the examples directory for more complete examples, including middleware and
OpenTelemetry integration. For in-memory integration tests, use
MinimalLambda.Testing (a WebApplicationFactory-style runtime shim).
- MinimalLambda β Core framework documentation
- MinimalLambda.Abstractions β Interfaces and abstractions
- MinimalLambda.OpenTelemetry β Observability documentation
- Examples β Sample Lambda functions demonstrating framework features
Contributions are welcome! Bug reports, suggestions, and pull requests are all appreciated. Please check the GitHub repository for guidelines.
This project is licensed under the MIT License. See LICENSE for details.