AwsLambda.Host.Abstractions
0.0.7-alpha.2
See the version list below for details.
dotnet add package AwsLambda.Host.Abstractions --version 0.0.7-alpha.2
NuGet\Install-Package AwsLambda.Host.Abstractions -Version 0.0.7-alpha.2
<PackageReference Include="AwsLambda.Host.Abstractions" Version="0.0.7-alpha.2" />
<PackageVersion Include="AwsLambda.Host.Abstractions" Version="0.0.7-alpha.2" />
<PackageReference Include="AwsLambda.Host.Abstractions" />
paket add AwsLambda.Host.Abstractions --version 0.0.7-alpha.2
#r "nuget: AwsLambda.Host.Abstractions, 0.0.7-alpha.2"
#:package AwsLambda.Host.Abstractions@0.0.7-alpha.2
#addin nuget:?package=AwsLambda.Host.Abstractions&version=0.0.7-alpha.2&prerelease
#tool nuget:?package=AwsLambda.Host.Abstractions&version=0.0.7-alpha.2&prerelease
AwsLambda.Host.Abstractions
⚠️ Development Status: This project is actively under development and not yet production-ready. Breaking changes may occur in future versions. Use at your own discretion in production environments.
Overview
AwsLambda.Host.Abstractions provides the core interfaces and delegates that define the contract for the aws-lambda-host framework. This package contains the essential abstractions you'll work with when building Lambda functions, including the handler builder pattern, invocation context, and lifecycle delegates.
Most developers using aws-lambda-host won't directly reference this package — it's implicitly used by AwsLambda.Host. However, it's useful if you're building custom integrations, middleware, or extensions for the framework.
Packages
The framework is divided into focused packages:
| Package | NuGet | Downloads |
|---|---|---|
| AwsLambda.Host | ||
| AwsLambda.Host.Abstractions | ||
| AwsLambda.Host.OpenTelemetry |
Each package has detailed documentation in its own README file.
Table of Contents
Core Abstractions
ILambdaApplication
The main builder interface for configuring a Lambda application. It follows the fluent builder pattern similar to ASP.NET Core Minimal APIs.
Key Methods:
MapHandler()– Register the main Lambda invocation handlerUse()– Add middleware to the invocation pipelineOnInit()– Register startup handlers during the Lambda init phaseOnShutdown()– Register shutdown handlers during the Lambda shutdown phase
Example Pattern:
var builder = LambdaApplication.CreateBuilder();
builder.Services.AddScoped<IMyService, MyService>();
var lambda = builder.Build();
lambda.MapHandler(async (context) => { /* handle invocation */ });
lambda.OnInit(InitializationHandler);
await lambda.RunAsync();
This builder pattern enables you to register handlers, add middleware, configure dependency injection, and manage the Lambda lifecycle declaratively.
ILambdaHostContext
Encapsulates all information about a single Lambda invocation. It extends AWS's standard
ILambdaContext and provides:
Event– The deserialized Lambda eventResponse– The handler's response (to be serialized back)ServiceProvider– Access to the scoped dependency injection containerItems– Key/value collection for invocation-scoped data sharingCancellationToken– Signals cancellation when Lambda timeout approaches
You'll receive this context in your handler, middleware, and throughout the invocation pipeline:
lambda.MapHandler(async (ILambdaHostContext context) =>
{
var input = context.Event as MyEventType;
var service = context.ServiceProvider.GetRequiredService<IMyService>();
context.Response = await service.ProcessAsync(input);
});
Handler Delegates
Three delegate types manage the Lambda lifecycle:
LambdaInvocationDelegate
Task LambdaInvocationDelegate(ILambdaHostContext context)
The core handler that processes Lambda invocations. Receives the invocation context and is responsible for setting the response.
LambdaStartupDelegate (also called LambdaInitDelegate)
Task<bool> LambdaInitDelegate(IServiceProvider services, CancellationToken cancellationToken)
Invoked during Lambda's init phase (before any handler invocation). Returns true to continue
initialization or false to abort. Useful for pre-initialization
during Snap Start.
LambdaShutdownDelegate
Task LambdaShutdownDelegate(IServiceProvider services, CancellationToken cancellationToken)
Invoked during Lambda's shutdown phase. Use this for cleanup (closing connections, flushing metrics, etc.). Multiple handlers can be registered.
Lambda Lifecycle
Lambda executes in three distinct phases:
- Init Phase – Runs once when the Lambda runtime initializes the function (or resumes from Snap
Start). Initialization code (like opening database connections) runs here and is reused across
invocations. Register handlers with
OnInit(). - Invocation Phase – Runs for each incoming event. Your
MapHandler()executes here, potentially multiple times for a single container. Each invocation is isolated with its own scoped dependency injection container. - Shutdown Phase – Runs once before the runtime shuts down the container. Use this for
cleanup (closing connections, flushing metrics, etc.). Register handlers with
OnShutdown().
The abstractions in this package align with these phases. For detailed information about the execution model and examples, see AwsLambda.Host.
For more details on the AWS Lambda runtime environment, see the AWS Lambda Runtime Environment documentation.
Installation
Install via NuGet:
dotnet add package AwsLambda.Host.Abstractions
Or specify a version:
dotnet add package AwsLambda.Host.Abstractions --version <version>
Contributing
Contributions are welcome! Please check the GitHub repository for contribution guidelines.
License
This project is licensed under the MIT License. See LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Amazon.Lambda.Core (>= 2.7.1)
-
net8.0
- Amazon.Lambda.Core (>= 2.7.1)
-
net9.0
- Amazon.Lambda.Core (>= 2.7.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on AwsLambda.Host.Abstractions:
| Package | Downloads |
|---|---|
|
AwsLambda.Host
.NET Host for AWS Lambda |
|
|
AwsLambda.Host.OpenTelemetry
OpenTelemetry for .NET Host for AWS Lambda |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.3 | 93 | 11/10/2025 |
| 0.1.2 | 79 | 11/10/2025 |
| 0.0.7-alpha.3 | 45 | 11/9/2025 |
| 0.0.7-alpha.2 | 40 | 11/9/2025 |
| 0.0.7-alpha.1 | 43 | 11/9/2025 |
| 0.0.6-alpha.1 | 126 | 11/6/2025 |
| 0.0.5-alpha.1 | 123 | 11/6/2025 |
| 0.0.4-alpha.3 | 129 | 11/2/2025 |
| 0.0.4-alpha.2 | 128 | 11/2/2025 |
| 0.0.4-alpha.1 | 130 | 11/2/2025 |
| 0.0.3-alpha.1 | 54 | 11/1/2025 |
| 0.0.2-alpha.10 | 131 | 10/30/2025 |
| 0.0.2-alpha.9 | 126 | 10/30/2025 |
| 0.0.2-alpha.8 | 128 | 10/30/2025 |
| 0.0.2-alpha.7 | 127 | 10/30/2025 |
| 0.0.2-alpha.6 | 119 | 10/30/2025 |
| 0.0.2-alpha.5 | 124 | 10/30/2025 |
| 0.0.2-alpha.3 | 120 | 10/30/2025 |
| 0.0.2-alpha.2 | 127 | 10/30/2025 |
| 0.0.2-alpha.1 | 131 | 10/29/2025 |
| 0.0.1-alpha.7 | 112 | 10/26/2025 |
| 0.0.1-alpha.6 | 108 | 10/26/2025 |