Building Lambda and its rule

After we have created a table on AWS DynamoDB, we can continue developing the AWS Lambda function. We will use Node.js runtime to write the program for AWS Lambda. Just navigate to https://console.aws.amazon.com/lambda from your browser. We will create the AWS Lambda function from scratch:

  1. Fill in your Lambda function name; for instance, aws-iot-button. Select Node.js for runtime and your existing role or create a new one if you don't have one. The Lambda role is important to ensure your Lambda has permission to access AWS DynamoDB. I will explain it in the last section:
  1. On your Lambda function dashboard, we develop a trigger to filter incoming messages from AWS IoT Button. Click on the Configuration section and select AWS IoT to add a new trigger, as shown in the following screenshot:
  1. On the Configure triggers panel, you select IoT Button for the IoT type. Fill in your AWS IoT Button hardware serial Device Serial Number (DSN). You can find it on the back of the hardware. Then, click on the Generate certificate and keys button to download the certificate:

Certificate and private key files should be uploaded to the AWS IoT Button hardware. You can do this task by referring to the explanation in the previous section.

  1. As I have stated regarding the Lambda role, we should configure it on https://console.aws.amazon.com/iam/. Select the Roles menu. Then, find the role name that is assigned on our AWS Lambda. Open it and you will see it on the Permissions tab.
  1. You should have AmazonDynamoDBFullAccess on the policy list. If not, please add the AmazonDynamoDBFullAccess policy into your role:

We have configured the AWS Lambda role in order to access AWS DynamoDB. Next, we will write a program for AWS Lambda

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.24.30