Create the Lambda Function


In this tutorial, we will be setting up resources in the AWS Oregon region (us-west-2). Before continuing, ensure that the region dropdown in the top right of your screen says Oregon.

To process data from the device, we will use a Kinesis stream and a Lambda function.

Below is the code of the lambda function that will be used to process the data being written to the Kinesis stream. You will cut and paste the source code in this function into the Lambda console.

  1. Open the Lambda console page by clicking Services > Lambda
  2. Press the blue Get Started Now button.
  1. Enter the name of the fuction and an optional description.

  2. Cut and paste the source code from the Javascript file at the URL listed above. Substitute the string “[TABLE_NAME]” with the name of the device table that was created in the CloudFormation stack.

  3. Select the role that was created from the CloudFormation stack in the previous step. It should have a name like [StackName]-DeviceExecutionRole-XXXXX

  4. Press Create. The function has now been created.

  5. Add an event source to the function by selecting “Actions->Add Event Source”

  6. Choose the Kinesis stream created by the CloudFormation stack as the event source.

  7. Press Submit. You should now see the Kinesis stream show up in the “Event Source” list beneath the function.


Congratulations!! You have now successfully set up your AWS backend infrastructure.