Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
saha-rajdeep committed Aug 27, 2020
1 parent 3a1f3c5 commit 8f33e74
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
*# Serverless Reference Architecture: IoT Backend*
# Serverless Reference Architecture: IoT Backend

The serverless IoT backend reference architecture is a general-purpose, event-driven, IoT data processing architecture that uses [AWS Lambda](_https://aws.amazon.com/lambda_). This architecture is ideal for workloads where IoT data needs to be ingested, custom rules applied and prepared for further analysis such as Machine Learning.

This architecture and sample implementation provides a framework for ingesting IoT messages utilizing [AWS IoT Core](https://aws.amazon.com/iot-core/) and AWS Lambda.

In this demo humidity sensor application, IoT soil-moisture sensors deliver messages to backend. IoT rule checks if humidity is under threshold, and invoke a Lambda function if that's the case. Lambda function sends an alert notification. All the IoT data is stored in S3 for downstream processing.

*## Architectural Diagram*
## Architectural Diagram*

![Reference Architecture - IoT Backend](_./iot-serverless-backend-architecture.png_)

*## Application Components*
## Application Components*

***Note***
**Note**
Downstream Data processing components in the architecture diagram - AWS IoT Analytics, Machine Learning, Amazon Kinesis Data Streams, and Amazon DynamoDB are not included in this deployment.

*### IoT Device/Thing*
### IoT Device/Thing

A soil moisture IoT sensor simulates a message with timestamp and soil humidity, and send the message to an IoT Topic using MQTT protocol.

*### IoT Device/Thing*
### IoT Device/Thing

The message from the sensor is delivered to IoT topic. IoT rules are automatically applied to the topic. Both IoT topic and rule are part of AWS IoT Core. IoT rule saves all messages to a S3 bucket. This IoT rule also checks if humidity in the message is less than certain threshold (set to 35 in this example). If humidity is below the threshold, this IoT rule invokes an AWS Lambda function. This Lambda function receives the message as input in the event field, parses the message to obtain device name and humidity, and sends an alert using SNS Topic.

*### Downstream Processing*
### Downstream Processing

As mentioned in the Note section, the downstream processing is not implemented as part of this deployment and is shown as art of possible. Machine Learning can be used on all humidity data to perform predictions, IoT messages can be streamed to another system using Kinesis Data Streams, or can simply be saved in DynamoDB to be queried later. IoT Analytics can be used on the data using out of the box graphs or custom analysis.

*## Running the Example*
## Running the Example

You can use the provided [AWS SAM template](_./iot-backend.yaml_) to launch a stack that demonstrates the Lambda file processing reference architecture. Details about the resources created by this template are provided in the *SAM Template Resources* section of this document.

*### Deploying the template*
### Deploying the template

** Important ** You can deploy the template in the following regions: `us-east-1` or `eu-west-1`.

Expand All @@ -43,7 +43,7 @@ Change the SNSEmail address parameter to your own email and run the command on y

or you can directly go to CloudFormation console and upload the template there.

*### Seeing the IoT messages and alerts*
### Seeing the IoT messages and alerts

After you successfully deploy the stack you will observe the following:

Expand All @@ -65,20 +65,18 @@ Humidity 32 under threshold for device name soilSensor2
5. To stop getting emails go to the email you received, in step 3, and click `sns-opt-out` that is at the bottom of that email.
6. To cleanup the resources after you are done, please perform the following steps.

*### Cleaning Up
*
### Cleaning Up

To delete all the resources created in this example you should follow the following steps:
1. Delete the s3 RuleFilterBucket: Go to S3 and your bucket will be with name like `iot-backend-rulefilterbucket-xxxxxxxxxxx`, delete all the contents of the bucket and then delete the bucket itself.
2. Delete the IoT Policy: Go to the IoT Core > Secure > Policies, select `serverless-iot-backend-policy` and delete it.
3. Delete the IoT Thing: Go to the IoT Core > Manage > Things, select `serverless-iot-backend-thing` and delete it.
4. Finally, you should go to CloudFormation console and select the stack with name `iot-backend` and click the delete button. This will delete all the other resources created in this example.

*## SAM Template Resources*
## SAM Template Resources

*### Resources*
[The provided template](_https://code.amazon.com/packages/ServerlessIoTBackendRefresh/blobs/mainline/--/iot-backend.yaml_)
creates the following resources:
### Resources
[The provided template](./iot-backend.yaml) creates the following resources:

- ***ECInstanceProfile*** - We need devices that will monitor the soil humidity/temperature. In this example we are using an EC2 instance that will simulate the data generated by devices and send it to the MQTT Queue. We are using SSM Systems Manager to launch this instance.

Expand All @@ -99,5 +97,3 @@ AWS Systems Manager is an AWS service that you can use to view and control your
- ***AlertSNSTopic*** - Amazon Simple Notification Service (SNS) is a highly available, durable, secure, fully managed pub/sub messaging service that enables you to decouple microservices, distributed systems, and serverless applications. Amazon SNS provides topics for high-throughput, push-based, many-to-many messaging. In our example we are using Amazon SNS topic, to fan out notifications to end users using email in case
soil humidity falls below certain threshold.



0 comments on commit 8f33e74

Please sign in to comment.