The Internet of Things on AWS – Official Blog

Streamline the process of developing IoT applications with Toolbox for AWS IoT

Introduction

Streamlining the development of Internet of Things (IoT) applications can help your company stand out. It can also
spur new innovations, such as connecting and leveraging data from countless devices to empower data-driven choices,
optimized operations, and creative new offerings in today’s fast-changing world. As IoT adoption grows, one of the
challenges that developers face is needing comprehensive testing capabilities. The importance of rigorous testing in
IoT development cannot be overstated. It ensures the reliability and performance of IoT applications in real-world
scenarios.

Toolbox for AWS IoT is a sample application to improve testing options, simplify IoT SQL statement development, and record and replay MQTT messages to help troubleshoot system functionality. With Toolbox for AWS IoT, developers can save hours of manual testing and accelerate the development of robust IoT applications.

Toolbox for AWS IoT is available on GitHub. The Repository contains an AWS Cloud Development Kit stack to deploy
a web frontend that is ready for an authenticated developer to use. Technical implementation details are described
in the GitHub Readme.

In this blog post, you learn how to use the Toolbox for AWS IoT to streamline your development process. The post
also provides resources and benefits that this open-source project offers, which can help you overcome testing
challenges.

Solution overview

Toolbox for AWS IoT currently provides two capabilities: Testing rules for AWS IoT SQL statements, and record and
replay functionality for MQTT messages. Both capabilities are described in more detail in the following sections.

Testing AWS IoT SQL statements

AWS IoT Core provides a fully managed set of MQTT-based messaging features that can help you build adaptive IoT architectures that are cost efficient, reliable, and optimized to scale. The ability to efficiently route and process data received from devices with Rules for AWS IoT is a key functionality that AWS IoT Core offers. Rules for AWS IoT helps you to analyze and perform actions on messages received through the AWS IoT Core MQTT broker. AWS IoT rules are defined using a SQL-like syntax with additional functionality, such as dynamically fetching data from Amazon DynamoDB or invoking an Amazon SageMaker machine learning model. Gaining visibility into potential errors or how the transformed message passed into the rule action can appear cumbersome. It usually requires you to configure additional troubleshooting helpers. For example, configuring an Amazon CloudWatch Logs action on the rule, which also requires you to manually identify the corresponding error message in the logs. Or, you need to create and save a test rule and then use the in-console MQTT client to trigger the rule by sending a message to topic the rule. To verify the output, you also need a custom solution like sending the message to another topic and subscribe to it.

Toolbox for AWS IoT offers an integrated, visual way to develop, validate, and optimize AWS IoT rule SQL statements.
This tool offers a way to avoid the extra work needed to create and configure IoT rules, and the necessary
infrastructure to validate the output. You can choose between two different input options (Figure 1):

  1. Custom message – you provide a sample message to apply the AWS IoT rule SQL statement.
  2. Topic message – you specify a MQTT topic, or wildcard, and the AWS IoT rule processes the first incoming
    message.

Figure 1
Figure 1: Frontend to define SQL statement and test payload

The result of applying the IoT rule to the input is displayed next to the input (Figure 2). This helps you to verify
what actions were applied by the SQL statements and if the result is as expected. By choosing the Run Test button,
you can retrieve the result within seconds.

Figure 2Figure 2: Results of rule evaluation against test payload

You can use the Toolbox for AWS IoT to test your IoT rule SQL statements without the need to manually create infrastructure or implement custom logic.

Record and replay MQTT messages

Recording and replaying MQTT messages allows you to test the application end-to-end testing during development.
Toolbox for AWS IoT provides the infrastructure and functionality to record, save, and replay MQTT messages.
Replaying messages supports testing on both sides – the IoT device and the cloud application. Both, the device and
the cloud application can receive the same messages repeatedly to reproduce errors and support integration testing.
For example, your application running in AWS can be tested continuously without needing to have physical devices
connected.

Recording MQTT messages

To start recording messages, select a topic and provide a recording name (Figure 3). When the recording starts, a
temporary AWS IoT rule is created, which persists all messages, user and MQTT properties, timestamp details, and the
recording identification into a DynamoDB table. When the recording stops, the respective AWS IoT rule is deleted and
no more messages are written to the DynamoDB table.

Figure 3
Figure 3: Frontend to manage MQTT message recordings

Replay MQTT messages

To start replaying messages from a recording, select the recording from a list. Optionally, you can specify a prefix to replay messages. For example, a recording used device/#/light1 to record messages on the light1 topic for all devices. Without specifying a prefix, the replay sends all messages to their original topic – this might look like, device/abc/light1 and device/def/light1. Similarly, when you specify a prefix, such as my-replay, the messages are replayed to my-replay/device/abc/light1. You can use prefixes to separate messages into different non-production environments for your application (such as development, test, or QA) and replay messages to those specific environments.

When the replay starts, a background task begins, iterates through the messages, and sends them to their respective MQTT topics in the original order and with the original delay between messages. You can run multiple replays of the same recording at the same time and monitor their status (Figure 4). You can also abort a replay at
any time.

Figure 4
Figure 4: Frontend to manage replays of recordings

Conclusion

In this post, we discussed how the Toolbox for AWS IoT can streamline IoT application development. By providing
capabilities to record and replay MQTT messages and test IoT SQL statements, Toolbox for AWS IoT eliminates tedious
manual testing and empowers you to validate your IoT applications thoroughly. To get started with Toolbox for AWS IoT visit the GitHub repository and follow the instructions to deploy the provided CDK stack. Once deployed, you can immediately start using Toolbox for AWS IoT for testing and development workflows.

For more information see the Toolbox for AWS IoT video on the AWS IoT YouTube channel.

 

About the Authors

David Boldt is a Solutions Architect at Amazon Web Services. He helps customers build secure and scalable solutions that meet their business needs. He specialized in IoT and Robotics to address industry-wide challenges, leveraging technologies to drive innovation, and efficiency across various sectors.

Daniel Moser is a Solutions Architect for AWS who works primarily with enterprise Travel and Transportation customers. He specializes in serverless technologies and works with customers to build, architect, and design solutions that meet their business needs. In his spare time, Daniel enjoys cooking and eating great food, tinkering with technology, and travelling to explore new cities and locations.