|
Important note Please note that this guide is for ThingsBoard versions prior v2.0. Old rules and plugins functionality is replaced by new rule engine components (rule chains and rule nodes). Please review new rule engine documentation to learn how to adopt new functionality. We are doing our best to modify this guide to v2.0 components. Contributions are welcome. |
SNS plugin is responsible for sending messages to Amazon Web Services Simple Notification Service topics triggered by specific rules
SNS Plugin has the following configuration parameters:
Access Key ID and Secret Access Key are the credentials of an AWS IAM User with programmatic access. More information on AWS access keys can be found here
Region must correspond to the one in which the SNS Queue(s) are created. Current list of AWS Regions can be found here
This plugin does not provide any server-side API.
In this example, we are going to demonstrate how you can configure this extension to be able to send a message to an SNS Topic every time new telemetry message for the device arrives.
Prerequisites before contining Kafka extension configuration:
The information on how to create SNS Topic can be found here
Let’s configure SNS plugin first. Go to Plugins menu and create new plugin:
Make sure to replace <$YOUR_ACCESS_KEY_ID> and <$YOUR_SECRET_ACCESS_KEY> placeholders with the actual values and set the right region.
Click on ‘Activate’ plugin button:
In order to create SNS Rule, go to Rules screen and click ‘Add New rule’ button.
Add filter for POST_TELEMETRY message type:
Click ‘Add’ button to add filter.
Then select ‘SNS Plugin’ in the drop-down box for the Plugin field:
Add action that will send temperature telemetry of device to the particular SNS Topic:
Click ‘Add’ button and then activate Rule.
SNS is a push-based service, so we need to create a subscription in order to receive messages from it. In AWS console under SNS Dashboard, go to Topics, select your topic, then click Action -> Subscribe to topic. In the window that appears, select Protocol: Email amd enter your email address:
Now you can send Telemetry message that contains ‘temp’ telemetry for any of your devices:
{"temp":88.2}
Here is an example of a command that publish single telemetry message to locally installed ThingsBoard:
mosquitto_pub -d -h "localhost" -p 1883 -t "v1/devices/me/telemetry" -u "$ACCESS_TOKEN" -m "{'temp':88.2}"
Now you should receive an email with the telemetry data in your mailbox: