Part 2 - Deploy serverless Basket service

Now that the DynamoDB table is up and ready, let’s strangle out the basket service. For this, you will use a Serverless Lambda Function. You will be using Visual Studio 2019 to deploy the Lambda project to your AWS account.

Deploying Function using Visual Studio 2019

Locate the Lambda Function

  1. Open the folder “SampleApp” on the desktop. Then open a solution file named “UnicornWorkshop.sln” in it.

    project sln

  2. The solution will open up in Visual Studio. Observe that the Solution Explorer has the following projects.


  3. The project you will deploy is the “BasketLambda” project. Right click on the project name and select the option “Publish to AWS Lambda”. This is one of the amazing features that comes with the AWS Toolkit for Visual Studio.

    publish option

    Click to learn more about the Basket Lambda function implementation details (Optional reading)

Configure AWS Lambda project

Now let’s walk through the various configurations needed to deploy the Lambda function to AWS. After hitting “Publish to AWS Lambda” you will observe the “Upload Lambda Function” wizard. That’s where you can configure the new Lambda function.

  1. For “Function Name”, enter BasketLambda. You can leave the remaining fields with their default values and hit “Next”.

    lambda name

  2. Next, you need to configure the permissions for the Lambda function. Since the Lambda function will be interacting with the DynamoDB that was configured earlier, we have pre-created a role for you. The role can be assigned by specifying the “Role Name” Select the drop down and you can see all the available roles for the Lambda function. Select the role “dynamodb-access-modernization-workshop-role”.

    lambda role

  3. You can leave the remaining fields with their default values and hit “Upload”.

    lambda upload

  4. This triggers a build and upload of the Lambda function project.

    lambda uploading

    Once your Lambda has uploaded successfully, the wizard will close automatically.

Confirm Deployment

You can now confirm that your Lambda function was created and deployed. In the AWS Manage Console, navigate to Lambda.

search lambda

In the Lambda Console, you can see that your new Lambda function has been uploaded!

search lambda

The Lambda function is used to modify user basket data, and since this is sensitive information, it is good practice to add a layer of Authentication. In the next part of the lab you will learn to set up this authentication layer using Cognito and test our Lambda function!