/aws-iot-rules-engine-to-lambda-sample

An example project showing how to set up AWS Lambda Powertools for Typescript to help understand the behavior of the AWS IoT Rules Engine with AWS Lambda integration.

Primary LanguageJavaScriptMIT No AttributionMIT-0

AWS IoT Rules Engine with AWS Lambda Action Example

This is a project built and deployed using AWS SAM, and accompanies the blog on How to ensure resilience for your AWS IoT Rules Engine to AWS Lambda integration.

The small demo application shows a basic configuration of AWS Lambda Powertools for Typescript tracer and logger using descriptors.

The Service Map and tracing are created and used to understand the asynchronous invocation behaviour of AWS Lambda from the AWS IoT Rules Engine. To demonstrate how AWS IoT Rules Engine works when invoking AWS Lambda and how AWS Lambda behaves when invoked asynchronously, a small Typescript Lambda function, app.ts, was created to return an error. Because AWS Lambda is invoked asynchronously, we will see that the AWS IoT Rules Engine receives a 202 response from AWS Lambda, even if the function execution fails. Also, as the SAM template shows how configuring a Destination for the AWS Lambda failed events helps with ensuring resilience (that no data goes missing).

Have a look at the blog to learn more.

High Level Architecture

high-level-arch

Build and deploy the application

You can use AWS SAM to build and run this test application.

To use the SAM CLI, you need to install the following tools:

To build and deploy your application for the first time, run the following in your shell:

sam build
sam deploy --guided 

Resources

To learn more about the following tools and services, click on the links provided:

  1. AWS SAM.
  2. Asynchronous AWS Lambda invocations

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.