LazyStack

Lambda Overview

Lambda functions are implemented as C# projects leveraging the AWS AspNetCoreServer class. This class allows Lambda Functions to act like standard .NET Core WepApi services where calls from an AWS ApiGateway are directed to AspNet Controller methods.

LazyStack calls the NSwag C# generator to generate C# AspNet Controller projects from the applications OpenApi specification. LazyStack also updates Lambda Project references to reference the appropriate Controller projects.

  • Each OpenApi tag generates:
    • Controller project.
    • Lambda Function project referencing the Controller project.
    • AWS::Serverless::Function resource in the serverless.template file.
  • Each OpenApi route (Path object + Operation object) is associated with a tag and generates:
    • Lambda Function Event for the tag's AWS::Serverless::Function resource.
    • Controller class method for handling the Lambda Function Event.
  • Each OpenApi component (schema) generates a class definition in the Schema project.

If you are not familiar with OpenApi and in particular how OpenApi tags are specified, you might review the OpenApi Specification. However, the examples in this documentation and the Tutorial make their use clear. The PetStore OpenApi specification used throughout our documentation and tutorial is similar to the OpenApi PetStore specification example.

LazyStack Lambda Functions are C# projects. When you publish your serverless stack, these projects are packaged up and copied into S3 storage. When a Lambda Function is called, AWS provisions an execution container using the appropriate packaged project from S3.

Example

In the PetStore OpenApi example, we have four OpenApi tags: order, orderSecure, pet and petSecure. LazyStack will generate/update the following projects: