Pre-requisites

Architecture

Untitled

Steps

  1. Create ASP.NET Core Web API project.

  2. Install Amazon.Lambda.AspNetCoreServer.Hosting NuGet package.

  3. Add a call to AddAWSLambdaHostingmethod when services are defined in your application.

    // Add AWS Lambda support.
    builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi);
    
    var app = builder.Build();
    

    Read more Introducing the .NET 6 runtime for AWS Lambda

  4. Open .csproj file and add the following tag in the PropertyGroup section.

    <AWSProjectType>Lambda</AWSProjectType>
    
  5. Now, You’re done with the API stuff for this demo.

  6. Create Lambda function in AWS Console.

  7. Deploy to AWS, when deploying, keep the function handler name the same as Assembly Name.

  8. Exposing the Web API using Amazon API Gateway

    1. Configure proxy integration, and deploy the API

      Untitled

      b. Update Lambda code to use LambdaEventSource.RestAPI instead.

      // Add AWS Lambda support.
      builder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi);
      
      var app = builder.Build();