AWSLambda.AspNetCoreAppMesh 1.0.5

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package AWSLambda.AspNetCoreAppMesh --version 1.0.5
NuGet\Install-Package AWSLambda.AspNetCoreAppMesh -Version 1.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AWSLambda.AspNetCoreAppMesh" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AWSLambda.AspNetCoreAppMesh --version 1.0.5
#r "nuget: AWSLambda.AspNetCoreAppMesh, 1.0.5"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install AWSLambda.AspNetCoreAppMesh as a Cake Addin
#addin nuget:?package=AWSLambda.AspNetCoreAppMesh&version=1.0.5

// Install AWSLambda.AspNetCoreAppMesh as a Cake Tool
#tool nuget:?package=AWSLambda.AspNetCoreAppMesh&version=1.0.5

Amazon Lambda ASP.NET Core App Mesh

You have a fleet of serverless ASP.NET Core apps configured as AWS Lambda functions. While AmazonLambdaClient.InvokeAsync() found in the AWSSDK.Lambda is a great way to achieve inter-Lambda communication, the method does not work for invocation of Lambdas running on your local machine. This library aims to fill this functionality gap by marshalling your requests using Kestrel when your ASP.NET Core lambdas are being debugged locally.

Roadmap

  • Catalog clients: auto-discover the catalog tool url (assess feasibility)
  • Support for Lambdas deployed behind an ALB
  • NET 3.1 support (dependant on AWS)

Example

Say you have an existing Invoke code such as this:

var invokeReq = new InvokeRequest();
invokeReq.FunctionName = "MyLambdaFunction";
invokeReq.InvocationType = InvocationType.RequestResponse;
// ... other params

var apiGatewayReq = new APIGatewayProxyRequest()
{
    HttpMethod = "GET",
    Path = "/home/index"
};

invokeReq.Payload = JsonConvert.SerializeObject(apiGatewayReq);

var lambdaClient = new AmazonLambdaClient(); // region, creds

var resp = await lambdaClient.InvokeAsync(invokeReq); // When running in AWS environment

// --- OR, WHEN DEBUGGING LOCALLY ---
// This will route the request to MyLambdaFunction running on your local machine

resp = await invokeReq.RouteAPIGatewayProxyRequestLocally();

Getting Started

Catalog Tool Installation

Catalog Tool keeps track of all the running Lambda ASP.NET Core Applications on your local machine that register to recieve incoming InvokeRequest requests.

dotnet tool install -g AWSLambda.AspNetCoreAppMesh.Catalog

Run the Catalog Tool

dotnet lambda-app-mesh --urls http://localhost:5050

The --urls param is optional. The tool will listen on port 5000 and 5001 by default.

Once the Catalog Tool is running, your ASP.NET Core applications will be able to register themselves with the catalog. Ensure the catalog url is resolvable and reachable by your applications.

See full Catalog Tool Documentation

Configuring Your ASP.NET Core Application to route InvokeRequest objects locally

In Startup.cs

public void ConfigureServices(IServiceCollection services)
{
	services.AddAWSLambdaAppMeshClient(opts =>
	{
		opts.LambdaName = "MyAspNetCoreLambda"; // name of your Lambda function
		opts.CatalogUrl = "http://localhost:5050"; // URL the Catalog Tool (dotnet lambda-app-mesh) is listening on
	});
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
	app.UseAWSLambdaAppMeshClient();
}

Now, you can call RouteAPIGatewayProxyRequestLocally() on your InvokeRequest requests. In order for InvokeRequest to be processed, the receiver ASP.NET Core Lambda must be running on your machine, and must have registered with the Catalog tool.

Configuring Your ASP.NET Core Application to receive incoming InvokeRequest requests

Ensure Catalog tool (dotnet lambda-app-mesh) is running prior to launching your ASP.NET Core apps. Otherwise, you'll get an exception when trying to register with the catalog.

In Startup.cs

public void ConfigureServices(IServiceCollection services)
{	
	services.AddAPIGatewayProxyFunctionEntryPoint<LambdaEntryPoint>(); // your APIGatewayProxyFunction entry point
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
	app.HandleIncomingAWSLambdaInvokeRequests(env);
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6.1 487 4/1/2020
1.0.6 433 4/1/2020
1.0.5 450 3/4/2020
1.0.4 459 2/29/2020
1.0.3 434 2/29/2020
1.0.2 459 2/29/2020
1.0.2-rc 401 2/29/2020
1.0.1 461 2/29/2020

v1.0.5 - Corrected a few error messages
v1.0.4 - Fixed issue with circular host registration
v1.0.3 - Improved ApplicationUrl discovery
v1.0.2 - Friendlier error messages
v1.0.1 - Intital Release