lambda-local-harness
1.0.1
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
<PackageReference Include="lambda-local-harness" Version="1.0.1" />
paket add lambda-local-harness --version 1.0.1
#r "nuget: lambda-local-harness, 1.0.1"
// 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 | Versions 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. |
-
.NETCoreApp 2.0
- Amazon.Lambda.APIGatewayEvents (>= 1.1.2)
- Amazon.Lambda.Core (>= 1.0.0)
- Amazon.Lambda.Serialization.Json (>= 1.2.0)
- AWSSDK.CloudWatch (>= 3.3.6)
- AWSSDK.CloudWatchLogs (>= 3.3.4.6)
- AWSSDK.SimpleNotificationService (>= 3.3.0.27)
- microsoft.aspnetcore (>= 2.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.