Skip to content

j-d-ha/minimal-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

191 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MinimalLambda

Main Build codecov Quality Gate Status License: MIT

Lambda-first hosting with Minimal API-inspired patterns – Familiar .NET ergonomics with handlers, DI, and middleware, purpose-built for AWS Lambda triggers.

πŸ“š View Full Documentation

Overview

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.

Key Features

  • Minimal API Pattern – Map handlers with lambda.MapHandler(...) just like app.MapGet() in ASP.NET Core – clean, declarative, and intuitive
  • Dependency Injection – Constructor and parameter injection using Microsoft.Extensions.DependencyInjection with 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

Packages

The framework is divided into multiple NuGet packages:

Core Packages

The core packages provide the fundamental hosting framework, abstractions, and observability support for building AWS Lambda functions.

Package NuGet Downloads
MinimalLambda NuGet Downloads
MinimalLambda.Abstractions NuGet Downloads
MinimalLambda.OpenTelemetry NuGet Downloads
MinimalLambda.Testing NuGet Downloads

Envelopes Packages

Envelope packages provide specialized support for handling different AWS Lambda event sources, including SQS, SNS, API Gateway, Kinesis, and more.

Package NuGet Downloads
MinimalLambda.Envelopes NuGet Downloads
MinimalLambda.Envelopes.Sqs NuGet Downloads
MinimalLambda.Envelopes.ApiGateway NuGet Downloads
MinimalLambda.Envelopes.Sns NuGet Downloads
MinimalLambda.Envelopes.Kinesis NuGet Downloads
MinimalLambda.Envelopes.KinesisFirehose NuGet Downloads
MinimalLambda.Envelopes.Kafka NuGet Downloads
MinimalLambda.Envelopes.CloudWatchLogs NuGet Downloads
MinimalLambda.Envelopes.Alb NuGet Downloads

Each package has detailed documentation in its own README file.

Quick Start

Install the NuGet package:

dotnet add package MinimalLambda

Create 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).

Documentation

Contributing

Contributions are welcome! Bug reports, suggestions, and pull requests are all appreciated. Please check the GitHub repository for guidelines.

License

This project is licensed under the MIT License. See LICENSE for details.

About

.Net Host for AWS Lambda

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages