AI/ML, AWS, Cloud Computing, Internet of Things (IoT)

3 Mins Read

Simple IoT Alert Notification Using AWS IoT Rule and SNS

Voiced by Amazon Polly


When we do automation in the industry or the field of smart agriculture, we will continuously monitor various parameters such as temperature, humidity, CO2, pressure, and so on. If a particular threshold exists, we will trigger the actuator based on the different parameters this will allow us to boost industrial production or control the climate in agricultural greenhouses.

Whenever some parameters threshold exceeds, we must notify the end users, in this blog we will look at how to include IoT alert notifications using an AWS IoT Rule and SNS. You can use the AWS IoT Rules Engine to describe how data sent to AWS IoT Core interact with AWS services. AWS IoT rules are made up of three parts: a SQL SELECT expression, a topic filtering, and a rule action. Data can be extracted from receiving MQTT messages using the SQL SELECT command. Amazon SNS allows you to deliver notifications to your consumers directly.


Creation of SNS Topic and Subscription

Before building an IoT rule, we must first construct an SNS topic and subscription to receive and deliver data to the endpoint specified in the subscription.

  1. Log into an AWS console, search SNS in the search bar, and navigate to the Amazon SNS service.
  2. In the Amazon SNS service, in the left corner, click topics, then choose create topic, select type as Standard, input the name IoT_alert leave the other options alone and click create topic. Just a matter of time IoT_alert Topic will be created.


3. In the Amazon SNS service console Choose IoT_alert, which is just before we created.

4. In the IoT_alert topic down below click subscription then click create subscription. In the protocol section select Email.

5. In the Endpoint section enter your email address then click create subscription.


6. After creating the subscription, we must confirm with entered email id. So, log on to entered email address and in your inbox, we can see the mail from AWS, click on Confirm subscription link to subscribe to the topic.


Customized Cloud Solutions to Drive your Business Success

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Creation of IoT Rule

  1. Go to Amazon IoT Core, select Message Routing on the left side of the IoT core console, and then click Rules.
  2. Choose Create Rule, enter IoT_alert_rule as the Rule name, then click Next.
  3. Select SQL version as 2016-03-23, then enter SELECT * FROM ‘device/12/IoT_alert’ WHERE temperature > 30 on the SQL statement, then click Next.
  4. In the Rule actions section, select action as simple Notification Service (SNS), then select SNS topic as arn:aws:sns:us-east-1:XXXXXXXXX-IoT_alert which is created in the previous step.
  5. Choose RAW as the message format, then in the IAM role section, select the create role option, then enter IoT_alert_role and click create.
  6. Down below click next finally review and click create option, the IoT_alert_rule will be created.


Data Ingestion and Testing

  1. To ingest the IoT data to AWS IoT core navigate to the AWS IoT core and click MQTT test client choose a publish option and a topic option.
  2. Enter the topic name as device/12/IoT_alert and message payload as {“temperature”: 27,”humidity”: 60} and click publish, similarly publish the message with different values as {“temperature”:35,”humidity”:65}.
  3. The second message has a temperature is > 30 so the IoT rule will trigger the SNS to send an email to the subscribed endpoint. Log into the registered email id and we can see the AWS Notification message from the SNS.



This blog taught us how to leverage IoT Rules and SNS for real-time notification. This will be used in many IoT applications for alert notifications when a specific threshold exceeds the typical value. Not only email notifications we can also invoke the different mobile and web application APIs.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best-in-industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding IoT Rule or SNS, and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThats offerings.


1. Will AWS IoT Rule support topic filtering?

ANS: – Yes, using IoT Rule we can select the necessary IoT topic.

2. What are the applications of Amazon SNS?

ANS: – Amazon SNS allows you to deliver notifications to your consumers directly. Amazon SNS sends SMS text messages to over 200 countries, mobile push alerts to Amazon, Apple, Android, and Microsoft devices, and email notifications.

WRITTEN BY Vasanth Kumar R

Vasanth Kumar R works as a Sr. Research Associate at CloudThat. He is highly focused and passionate about learning new cutting-edge technologies including Cloud Computing, AI/ML & IoT/IIOT. He has experience with AWS and Azure Cloud Services, Embedded Software, and IoT/IIOT Development, and also worked with various sensors and actuators as well as electrical panels for Greenhouse Automation.



    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!