lambda-local-harness 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package lambda-local-harness --version 1.0.1
NuGet\Install-Package lambda-local-harness -Version 1.0.1
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="lambda-local-harness" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add lambda-local-harness --version 1.0.1
#r "nuget: lambda-local-harness, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install lambda-local-harness as a Cake Addin
#addin nuget:?package=lambda-local-harness&version=1.0.1

// Install lambda-local-harness as a Cake Tool
#tool nuget:?package=lambda-local-harness&version=1.0.1

lambda-local-harness

Wraps up an AWS lambda function, inside an API, to allow local testing.

Supports Lambda functions, that are created to be run with an api gateway e.g. have the main function, similar to

[LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
public async Task<APIGatewayProxyResponse> Handler(APIGatewayProxyRequest request, ILambdaContext context)

Usage

Create a new console project, and install using nuget

Instantiate your lambda function, such as

var function = new Function(
        new SnsPublisher(
                new Settings()),
                new TelemetryClient());

Then instantiate the lambda host api harness, passing in any environment variables as a dictionary such as

using (var host = new LambdaHost(function, new Dictionary<string, string>
{
        { "Environment", "local"},
        { "SnsTopic", "arn:aws:sns:eu-west-2:00000000:topic"},
        { "AppInsightsInstrumentationKey", "NOT SET"}
}))
{
        host.Wait();
}        

When the application starts, the console will advise of the port to call the lambda on, and you should be able to call the lambda, as if it were attached to from api gateway.

Full example:

class Program
{
        static void Main(string[] args)
        {
                var function = new Function(
                        new SnsPublisher(
                                new Settings()),
                                new TelemetryClient());
                        
                using (var host = new LambdaHost(function, new Dictionary<string, string>
                {
                        { "Environment", "local"},
                        { "SnsTopic", "arn:aws:sns:eu-west-2:00000000:marketing-opt-out-messages"},
                        { "AppInsightsInstrumentationKey", "NOT SET"}
                }))
                {
                        host.Wait();
                }
        }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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
2.0.2 1,118 5/14/2018
2.0.1 1,043 5/14/2018
2.0.0 1,048 5/10/2018
1.0.3 1,038 5/10/2018
1.0.2 1,039 5/10/2018
1.0.1 1,060 4/12/2018
1.0.0 1,075 4/12/2018