Skip to content

shawnspeak/nbasis-lambda

Repository files navigation

NBasis.Lambda NuGet Prerelease Version

Simplifies and standardizes the construction of AWS Lambdas with dotnet. Additionally the NBasis.Lambda.RuntimeSupport makes docker based lambdas easy.

Features:

  • Uses IServiceProvider for IoC throughout the function
  • IConfiguration is available with the Environment variables included

A simple S3 event function

First, install the NBasis.Lambda NuGet package into your app.

dotnet add package Amazon.Lambda.S3Events
dotnet add package NBasis.Lambda

Next, add a function class to your project based on NBasis.Lambda.BaseEventFunction

using Amazon.Lambda.S3Events;
using NBasis.Lambda;

public class S3EventFunction : BaseEventFunction<S3Event, S3EventHandler>
{
    protected override void SetupServices(IServiceCollection services) 
    {
        // add any services needed for your handler
    }
}

Then, add a handler class which inherits from NBasis.Lambda.IHandleLambdaEvent

using NBasis.Lambda;

public class S3EventHandler : IHandleLambdaEvent<S3Event>
{
    // services can be passed to the constructor
    public S3EventHandler() 
    {
    }

    public async Task HandleEventAsync(S3Event input, ILambdaContext context)
    {
    }
}

Finally, update your CloudFormation template (or pulumi, teraform, etc) with the handler path

"S3EventHandler" : {
    "Type" : "AWS::Serverless::Function",
    "Properties": {
        "Handler": "Simple3Event::Simple3Event.S3EventFunction::FunctionHandler",

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages