Part 1 - Create the NuGet package

1. Clone the repo

2. Create an S3 bucket for your Lambda functions

  • Log in to AWS Console and create a new S3 bucket
  • Name it as lambdaapps

3. Create an Amazon SQS Queue

  • Login to AWS Console and navigate to the Amazon SQS home page and click on Create New Queue
  • Select Standard Queue
  • Name the Queue OrdersToProcess
  • Click Quick-Create Queue

4. Create a Parameter Store Key

We will use this parameter store key to store the Queue URL which will be fetched by the Lambda to send Order messages to SQS - Login to AWS Console and navigate to AWS Systems Manager service home page - Click on Explore Parameter store - Click Create Parameter - Name the string as OrdersQueueName - Select the Type as String - Copy paste the URL of the OrdersToProcess queue - Click Create parameter

5. Create an IAM Role for the Lambda function to assume

  • Create a new IAM Role and name it OrdersProcessorRole
  • Attach the AmazonSQSFullAccess policy to it
  • Create a new Inline policy containing the following json attached to the IAM Role

    {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "ssm:GetParameter",
            "Resource": "<ARN of the Parameter Store Key>"
        }
    ]
    }

6. Create the .NET Library

  • Go to QueueHelperLibrary folder on the Git repo you cloned earlier. This is a class library project which uses Amazon SQS and AWS Systems Manager packages from AWS SDK for .NET
  • Open the solution in Visual Studio and compile it to ensure there are no errors

7. Publish a NuGet Package

  • Go to Project Properties on Visual Studio. Select the Pack
  • You should see a .nupkg file under ..\bin\Release path
  • Copy this file to a folder location that you can access easily Set a local NuGet Package store on Visual Studio
  • On Visual Studio go to Tools -> Options -> NuGet Package Manager -> Package Sources
  • Point the new package source location to the new folder location where you placed the .nupkg file in the earlier step
  • Give it a custom name like Local NuGet Store
  • Optionally, you can also setup your own NuGet Server on your own local machine by simply creating a new Empty ASP.NET Framework application and adding the NuGet.Server package to it from the NuGet store. This will add all the components required for you to host a local NuGet store locally.
  • On the project’s web.config file, change the value to “false” for “requireApiKey” setting

    <add key="requireApiKey" value="false"/>
  • Press F5 to run the local NuGet server. While the server is running, you can simply push the package to the NuGet store using the following command

    dotnet nuget  push <LOCAL_NUGET_PACKAGE_PATH> -s <LOCAL_NUGETSERVER_PATH>