Objective

You will now implement the AWS Lambda function to scan the records from the DynamoDB. We have assumed that the records have already been written to the table as demonstrated in this learning path on creating IoT applications with WoA and AWS IoT Core .

Create and configure an AWS Lambda function

Go the AWS Lambda console. Then, create the function as shown below:

  1. Click the Create function button:

Image Alt Text:fig1

  1. This opens a Create function wizard, in which you:
  • Select Author from scratch.
  • Type GetAverageTemperature for the Function name.
  • Select Node.js 20.x as the Runtime.
  • Select arm64 under Architecture.

At this point your wizard should look as per the image below:

Image Alt Text:fig2

Next, in the Create function wizard expand Change default execution role, and proceed as follows:

  1. Select Create a new role from AWS policy templates.
  2. Type role-lambda-to-dynamodb under the Role name.
  3. Under Policy templates - optional select Simple microservice permissions.

Image Alt Text:fig3

This ensures that your AWS Lambda function has all the necessary permissions to access the items in the DynamoDB table.

Finally, scroll down and click the Create function button. This will take you to the GetAverageTemperature function dashboard:

Image Alt Text:fig4

In the next step, you will use this dashboard to modify the function code.

Back
Next