SlideShare a Scribd company logo
1 of 38
Download to read offline
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Jinesh Varia | @jinman
October 8, 2015
MBL312
AWS IoT Deep Dive
Programming the Physical World with
Shadows and Rules
AWS IoT
“Securely connect one or one billion devices to AWS,
so they can interact with applications and other devices”
AWS IoT
DEVICE SDK
Set of client libraries to
connect, authenticate and
exchange messages
DEVICE GATEWAY
Communicate with devices via
MQTT and HTTP
AUTHENTICATION
AUTHORIZATION
Secure with mutual
authentication and encryption
RULES ENGINE
Transform messages
based on rules and
route to AWS Services
AWS Services
- - - - -
3P Services
DEVICE SHADOW
Persistent thing state
during intermittent
connections
APPLICATIONS
AWS IoT API
DEVICE REGISTRY
Identity and Management of
your things
In this session, we are going to dive deep
RULES ENGINE
Transform messages
based on rules and
route to AWS Services
DEVICE SHADOW
Persistent thing state
during intermittent
connections
An Example: Connected Vacuum Cleaner
Sweeps (duh!)
Reports its state via events:
• power, battery
• status (DOCKED,
RUNNING),
• bin.lastEmptied,
• bin.used,
• firmware version,
• filter.lastChanged,
• filter.usageMinutes,
• next run time
Mobile Phone can
• Initiate “Sweep”
• Receives Push
Notifications
• Show Current State
• Track History of Cleans
• Track Path and Uncleaned
Areas
• Initiate Firmware Updates
Wi-Fi Connected
Vacuum Cleaner
Mobile App to
Control the Device
AWS IoT Rules Engine Basics
SELECT * FROM ‘things/thing-2/color’
WHERE color = ‘red’
Rule
Name
Description
SQL Statement
Array of Actions AWS Services, Native
Simple & Familiar Syntax
- SQL Statement to define topic filter
- Optional WHERE clause
- Advanced JSON support
Functions improve signal : noise
- String manipulation (regex support)
- Mathematical operations
- Context based helper functions
- Crypto support
- UUID, Timestamp, rand, etc.
AWS IoT Rules Engine Basics
SELECT * FROM ‘things/thing-2/color’
WHERE color = ‘red’
AWS IoT Rules Engine’s Flexibility
SELECT *, clientId() as MQTTClientId
FROM 'one/rule'
WHERE
startsWith(topic(2), ’Vac123') AND
(state = ‘SWEEP' OR bin.size < 30)",
"actions":
[{
"republish": {
"topic":
"controllers/${substring(topic(3),
3, 5)}",
}]
AWS IoT – SQL Reference
SELECT DATA FROM TOPIC WHERE FILTER
AWS IoT Rules Engine – Format
{
"sql":"SELECT 'IDLE' AS status FROM 'vacuum/+/events' WHERE
event = 'COMPLETE'",
"actions": [
{
"dynamoDB": {
"tableName":"vaccum-status",
"hashKeyField":"vacuum_id",
"hashKeyValue":"${topic(2)}",
"payloadField":"statusDocument",
"roleArn":"arn:aws:iam::77777:role/rules_action_ddb"
}
}
]
}
AWS IoT – SQL Reference
SELECT DATA FROM TOPIC WHERE FILTER
• Like scanning a database table
• Default source is an MQTT topic
EXAMPLES:
• FROM mqtt(‘my/topic’)
• FROM mqtt(‘my/wildcard/+/topic’)
• FROM (‘my/topic’)
AWS IoT – SQL Reference
SELECT DATA FROM TOPIC WHERE FILTER
• Properties from the JSON Object in the payload
• “.” Operator
• “..” Operator
• “*” Operator
• Apply functions to attribute value
AWS IoT – SQL Reference
SELECT DATA FROM…
• SELECT *
• SELECT deviceid, temp
• SELECT coords.latitude
• SELECT a.another_level.b
• Returns {“b” : 3}
• SELECT a..b
• Returns {“b” : 3}
{
“deviceid” : “iot123”,
“temp” : 54,
“humidity” : 32,
“coords” : {
“latitude” : 47.615694,
“longitude” : -122.3359976
},
“a” : {
“another_level” : {
{“b” : 3},
{“b” : 5}
}}
}
SAMPLE PAYLOAD
AWS IoT – SQL Reference
SELECT DATA FROM…
• SELECT deviceid AS client
• SELECT md5(deviceid) AS hashed_id
Substitution Templates
• ${expression}
• ${topic() - md5(deviceid)}
• ${deviceid - temp}
{
“deviceid” : “iot123”,
“temp” : 54,
“humidity” : 32,
“coords” : {
“latitude” : 47.615694,
“longitude” : -122.3359976
},
“a” : {
“another_level” : {
{“b” : 3},
{“b” : 5}
}}
}
SAMPLE PAYLOAD
AWS IoT – SQL Reference
SELECT DATA FROM TOPIC WHERE FILTER
Token Meaning Example
= Equal, comparison color = 'red'
<> Not Equal, comparison color <> 'red'
AND Logical AND color = 'red' AND siren = 'on'
OR Logical OR color = 'red' OR siren = 'on'
() Parenthesis, grouping color = 'red' AND (siren = 'on' OR isTest)
+ Addition, arithmetic 5 + 3
- Substitution, arithmetic 5 - 4
/ Division, arithmetic 8 / 2
AWS IoT – SQL Reference
SELECT DATA FROM TOPIC WHERE FILTER
Token Meaning Example
< Less than, comparison color = 'red'
<= Less than or equal color <> 'red'
> Greater than, comparison color = 'red' AND siren = 'on'
>= Greater than or equal color = 'red' OR siren = 'on'
CASE …
WHEN …
THEN …
ELSE …
END
Case statement CASE location
WHEN 'home’
THEN 'off'
WHEN 'work’
THEN 'on' ELSE 'silent' END
AWS IoT – SQL Reference
SELECT DATA FROM TOPIC WHERE FILTER
• Properties from the JSON Object in the payload
• “.” Operator
• “..” Operator
• “*” Operator
• Apply functions to attribute value
AWS IoT Rules Engine Actions
RULES ENGINE
Transform messages
based on rules and
route to AWS Services
AWS Services
- - - - -
3P Services
AWS Services
- - - - -
3P Services
1. AWS Services
(Direct Integration)
Rules Engine
Actions
AWS IoT Rules Engine
AWS
Lambda
Amazon
SNS
Amazon
SQS
Amazon
S3
Amazon
Kinesis
Amazon
DynamoDB Amazon RDS
Amazon
Redshift
Amazon Glacier
Amazon
EC2
3. External Endpoints
(via Lambda and SNS)
Rules Engine connects AWS
IoT to External Endpoints and
AWS Services.
2. Rest of AWS
(via Amazon Kinesis, AWS
Lambda, Amazon S3, and
more)
AWS IoT Rules Engine
Rules Engine evaluates inbound
messages published into AWS
IoT, transforms and delivers to the
appropriate endpoint based on
business rules.
External endpoints can be
reached via Lambda and Amazon
Simple Notification Service
(Amazon SNS).
Invoke a Lambda function
Put object in an S3 bucket
Insert, Update, Read from a
DynamoDB table
Publish to an SNS Topic
or Endpoint
Publish to an Amazon Kinesis
stream
Actions
Publish to Amazon Kinesis
Firehose
Republish to AWS IoT
AWS IoT to AWS Lambda to and External Endpoint
Lambda Function
Rules Engine
PolicyPrivate Key
& Certificate
Thing/Device
Rule
SDK
AWS IoT AWS Services
Execution
Role
Policy
External Endpoint
Permission
Select * from ‘iotbutton/+’
Action
AWS IoT to Amazon DynamoDB to Dashboard
DynamoDB Table
Rules Engine
PolicyPrivate Key
& Certificate
Thing/Device
Rule
SDK
AWS IoT AWS Services
Policy
Dashboard
IAM
Role
Select * from ‘iotbutton/+’
Action
DynamoDB S3 Website
AWS IoT Rules Engine for Machine Learning
Anomaly Detection
Amazon Machine Learning can feed predictive evaluation criteria to the Rules Engine
Continuous Improvement Around Predication
Continuously look for outliers and re-calibrate the Amazon Machine Learning models
Send to S3
Amazon
Machine
Learning
Re-Train
S3
AWS IoT Rules Engine & Stream Data
N:1 Inbound Streams of Sensor Data (Signal to Noise Reduction)
Rules Engine filters, transforms sensor data then sends aggregate to Amazon Kinesis
Amazon Kinesis Streams to Enterprise Applications
Simultaneously stream processed data to databases, applications, other AWS
Services
Ordered Stream
Amazon
Kinesis
In this session, we are going to dive deep
RULES ENGINE
Transform messages
based on rules and
route to AWS Services
DEVICE SHADOW
Persistent thing state
during intermittent
connections
AWS IoT Device Shadow
Shadow
Virtual representation
of your device in the
cloud
• Device State
• desired
• reported
• Device metadata
• Sensors
• Version
• clientToken
• timestamp
AWS IoT Shadow Flow
Shadow
Device SDK
1. Device Publishes Current State
2. Persist JSON Data Store
3. App requests device’s current state
4. App requests change the state
5. Device Shadow sync’s
updated state
6. Device Publishes Current State
7. Device Shadow confirms state change
AWS IoT
AWS IoT Device Shadow Topics (MQTT)
Thing SDK (C-SDK, JS-SDK)
makes it easy for you build shadow
functionality into your device so it
can automatically synchronize the
state with the device.
AWS IoT Thing Shadow
UPDATE: $aws/things/{thingName}/shadow/update
DELTA: $aws/things/{thingName}/shadow/update/delta
GET: $aws/things/{thingName}/shadow/get
DELETE: $aws/things/{thingName}/shadow/delete
Sensor Reported Desired Delta
LED1 RED YELLOW
LED1 =
Yellow
TEMP = 60F
ACCEL X=1,Y=5,Z=4 X=1,Y=5,Z=4
TEMP 83F 60F
Thing Shadow – Document Format
{
“state”: {
“desired” : {
“color”: “RED”,
“sequence” :
[
“RED”,
“GREEN”,
“BLUE”]
},
“reported” : {
“color” :
“GREEN”
}
}
“metadata” : {
“desired” : {
“color” : {
“timestamp” : 12345
},
“sequence” : {
“timestamp” : 12345
}
},
},
“version” : 10,
“clientToken” : “Unique-client-token”,
“timestamp” : 123456
}
Demo: Avnet Broadcom WICED
Automatically clean when lights go off (night time)
desired: {
“status”: “RUNNING”
}
shadow/update update/accepted
Republish vacuum/shadow/update
vacuum/update/delta
reported: {
“AmbientLightValue”: 55
}
Rules Engine
Shadow
Shadow
One sensor automatically triggering the other device!
Select * from $/update/accepted where
AmbientLightValue <100
Automatically clean when lights go off (night time)
desired: {
“status”: “RUNNING”
}
shadow/update update/accepted
Republish vacuum/shadow/update
vacuum/update/delta
reported: {
“AmbientLightValue”: 55
}
Rules Engine
Shadow
Shadow
One sensor automatically triggering the other device!
Select * from $/update/accepted where
AmbientLightValue <100
Turn Off Automatic Cleaning At Night or Trigger
Manually using the Mobile App
Android App
UpdateThingShadow
Desired: {
“status”: “RUNNING”
}
$aws/things/light/update
$a/vacuum/update/delta
Shadow
Shadow
AWS IoT
DEVICE SDK
Set of client libraries to
connect, authenticate and
exchange messages
DEVICE GATEWAY
Communicate with devices via
MQTT and HTTP
AUTHENTICATION
AUTHORIZATION
Secure with mutual
authentication and encryption
RULES ENGINE
Transform messages
based on rules and
route to AWS Services
AWS Services
- - - - -
3P Services
DEVICE SHADOW
Persistent thing state
during intermittent
connections
APPLICATIONS
AWS IoT API
DEVICE REGISTRY
Identity and Management of
your things
Thank you!
Remember to complete
your evaluations!

More Related Content

What's hot

What's hot (20)

AWS January 2016 Webinar Series - Getting Started with AWS IoT
AWS January 2016 Webinar Series - Getting Started with AWS IoTAWS January 2016 Webinar Series - Getting Started with AWS IoT
AWS January 2016 Webinar Series - Getting Started with AWS IoT
 
Introduction to AWS IoT
Introduction to AWS IoTIntroduction to AWS IoT
Introduction to AWS IoT
 
AWS IoT introduction
AWS IoT introductionAWS IoT introduction
AWS IoT introduction
 
(MBL203) Drones to Cars: Connecting the Devices in Motion to the Cloud
(MBL203) Drones to Cars: Connecting the Devices in Motion to the Cloud(MBL203) Drones to Cars: Connecting the Devices in Motion to the Cloud
(MBL203) Drones to Cars: Connecting the Devices in Motion to the Cloud
 
Introducing AWS IoT - Interfacing with the Physical World - Technical 101
Introducing AWS IoT - Interfacing with the Physical World - Technical 101Introducing AWS IoT - Interfacing with the Physical World - Technical 101
Introducing AWS IoT - Interfacing with the Physical World - Technical 101
 
Getting Started with AWS IoT - September 2016 Webinar Series
Getting Started with AWS IoT - September 2016 Webinar SeriesGetting Started with AWS IoT - September 2016 Webinar Series
Getting Started with AWS IoT - September 2016 Webinar Series
 
AWS IoT - Best of re:Invent Tel Aviv
AWS IoT - Best of re:Invent Tel AvivAWS IoT - Best of re:Invent Tel Aviv
AWS IoT - Best of re:Invent Tel Aviv
 
Getting Started with AWS IoT
Getting Started with AWS IoTGetting Started with AWS IoT
Getting Started with AWS IoT
 
(MBL311) NEW! AWS IoT: Securely Building, Provisioning, & Using Things
(MBL311) NEW! AWS IoT: Securely Building, Provisioning, & Using Things(MBL311) NEW! AWS IoT: Securely Building, Provisioning, & Using Things
(MBL311) NEW! AWS IoT: Securely Building, Provisioning, & Using Things
 
Deep Dive on AWS IoT
Deep Dive on AWS IoTDeep Dive on AWS IoT
Deep Dive on AWS IoT
 
iNTRODUCTION TO AWS IOT
iNTRODUCTION TO AWS IOTiNTRODUCTION TO AWS IOT
iNTRODUCTION TO AWS IOT
 
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
 
(MBL204) State of The Union: IoT Powered by AWS
(MBL204) State of The Union: IoT Powered by AWS(MBL204) State of The Union: IoT Powered by AWS
(MBL204) State of The Union: IoT Powered by AWS
 
IoT Hack Day: AWS Pop-up Loft Hack Series Sponsored by Intel
IoT Hack Day: AWS Pop-up Loft Hack Series Sponsored by IntelIoT Hack Day: AWS Pop-up Loft Hack Series Sponsored by Intel
IoT Hack Day: AWS Pop-up Loft Hack Series Sponsored by Intel
 
Reply Webinar Online - Mastering AWS - IoT Foundations
Reply Webinar Online - Mastering AWS - IoT FoundationsReply Webinar Online - Mastering AWS - IoT Foundations
Reply Webinar Online - Mastering AWS - IoT Foundations
 
Srv204 Getting Started with AWS IoT
Srv204 Getting Started with AWS IoTSrv204 Getting Started with AWS IoT
Srv204 Getting Started with AWS IoT
 
AWS Services Overview - September 2016 Webinar Series
AWS Services Overview - September 2016 Webinar SeriesAWS Services Overview - September 2016 Webinar Series
AWS Services Overview - September 2016 Webinar Series
 
An Intro to AWS IoT
An Intro to AWS IoTAn Intro to AWS IoT
An Intro to AWS IoT
 
AWS IoT Webinar
AWS IoT WebinarAWS IoT Webinar
AWS IoT Webinar
 
Deep Dive on AWS IoT Core
Deep Dive on AWS IoT CoreDeep Dive on AWS IoT Core
Deep Dive on AWS IoT Core
 

Viewers also liked

Viewers also liked (7)

Enterprise-Grade IoT Infrastructure and Connectivity on AWS
Enterprise-Grade IoT Infrastructure and Connectivity on AWSEnterprise-Grade IoT Infrastructure and Connectivity on AWS
Enterprise-Grade IoT Infrastructure and Connectivity on AWS
 
Internet of things architecture perspective - IndicThreads Conference
Internet of things architecture perspective - IndicThreads ConferenceInternet of things architecture perspective - IndicThreads Conference
Internet of things architecture perspective - IndicThreads Conference
 
Workshop AWS IoT @ SIDO
Workshop AWS IoT @ SIDOWorkshop AWS IoT @ SIDO
Workshop AWS IoT @ SIDO
 
AWS re:Invent 2016: Introduction to AWS IoT in the Cloud (IOT204)
AWS re:Invent 2016: Introduction to AWS IoT in the Cloud (IOT204)AWS re:Invent 2016: Introduction to AWS IoT in the Cloud (IOT204)
AWS re:Invent 2016: Introduction to AWS IoT in the Cloud (IOT204)
 
Building Intelligent Solutions with AWS IoT
Building Intelligent Solutions with AWS IoT Building Intelligent Solutions with AWS IoT
Building Intelligent Solutions with AWS IoT
 
Developing Connected Applications with AWS IoT - Technical 301
Developing Connected Applications with AWS IoT - Technical 301Developing Connected Applications with AWS IoT - Technical 301
Developing Connected Applications with AWS IoT - Technical 301
 
Internet of Things: Patterns For Building Real World Applications
Internet of Things: Patterns For Building Real World ApplicationsInternet of Things: Patterns For Building Real World Applications
Internet of Things: Patterns For Building Real World Applications
 

Similar to (MBL312) NEW! AWS IoT: Programming a Physical World w/ Shadows & Rules

Similar to (MBL312) NEW! AWS IoT: Programming a Physical World w/ Shadows & Rules (20)

Overview of IoT Infrastructure and Connectivity at AWS & Getting Started with...
Overview of IoT Infrastructure and Connectivity at AWS & Getting Started with...Overview of IoT Infrastructure and Connectivity at AWS & Getting Started with...
Overview of IoT Infrastructure and Connectivity at AWS & Getting Started with...
 
AWS IoT Deep Dive
AWS IoT Deep DiveAWS IoT Deep Dive
AWS IoT Deep Dive
 
IoT Smart Home
IoT Smart HomeIoT Smart Home
IoT Smart Home
 
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
 
以Device Shadows與Rules Engine串聯實體世界
以Device Shadows與Rules Engine串聯實體世界以Device Shadows與Rules Engine串聯實體世界
以Device Shadows與Rules Engine串聯實體世界
 
Programming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules EngineProgramming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules Engine
 
(MBL205) New! Everything You Want to Know About AWS IoT
(MBL205) New! Everything You Want to Know About AWS IoT(MBL205) New! Everything You Want to Know About AWS IoT
(MBL205) New! Everything You Want to Know About AWS IoT
 
IOT203_Getting Started with AWS IoT
IOT203_Getting Started with AWS IoTIOT203_Getting Started with AWS IoT
IOT203_Getting Started with AWS IoT
 
Getting Started with AWS IoT - IOT203 - re:Invent 2017
Getting Started with AWS IoT - IOT203 - re:Invent 2017Getting Started with AWS IoT - IOT203 - re:Invent 2017
Getting Started with AWS IoT - IOT203 - re:Invent 2017
 
Programming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules EngineProgramming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules Engine
 
AWS IoT 및 Mobile Hub 서비스 소개 (김일호) :: re:Invent re:Cap Webinar 2015
AWS IoT 및 Mobile Hub 서비스 소개 (김일호) :: re:Invent re:Cap Webinar 2015AWS IoT 및 Mobile Hub 서비스 소개 (김일호) :: re:Invent re:Cap Webinar 2015
AWS IoT 및 Mobile Hub 서비스 소개 (김일호) :: re:Invent re:Cap Webinar 2015
 
SRV408 Deep Dive on AWS IoT
SRV408 Deep Dive on AWS IoTSRV408 Deep Dive on AWS IoT
SRV408 Deep Dive on AWS IoT
 
AWS IoT - Introduction - Pop-up Loft
AWS IoT - Introduction - Pop-up LoftAWS IoT - Introduction - Pop-up Loft
AWS IoT - Introduction - Pop-up Loft
 
Reply Bootcamp Rome - Mastering AWS - IoT Bootcamp
Reply Bootcamp Rome - Mastering AWS - IoT BootcampReply Bootcamp Rome - Mastering AWS - IoT Bootcamp
Reply Bootcamp Rome - Mastering AWS - IoT Bootcamp
 
Implementare e gestire soluzioni per l'Internet of Things (IoT) in modo rapid...
Implementare e gestire soluzioni per l'Internet of Things (IoT) in modo rapid...Implementare e gestire soluzioni per l'Internet of Things (IoT) in modo rapid...
Implementare e gestire soluzioni per l'Internet of Things (IoT) in modo rapid...
 
SRV408 Deep Dive on AWS IoT
SRV408 Deep Dive on AWS IoTSRV408 Deep Dive on AWS IoT
SRV408 Deep Dive on AWS IoT
 
Getting started with aws io t.compressed.compressed
Getting started with aws io t.compressed.compressedGetting started with aws io t.compressed.compressed
Getting started with aws io t.compressed.compressed
 
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech TalksEssential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
 
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
 
AWS IoT 深入探討
AWS IoT 深入探討AWS IoT 深入探討
AWS IoT 深入探討
 

More from Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

(MBL312) NEW! AWS IoT: Programming a Physical World w/ Shadows & Rules

  • 1. © 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Jinesh Varia | @jinman October 8, 2015 MBL312 AWS IoT Deep Dive Programming the Physical World with Shadows and Rules
  • 2. AWS IoT “Securely connect one or one billion devices to AWS, so they can interact with applications and other devices”
  • 3. AWS IoT DEVICE SDK Set of client libraries to connect, authenticate and exchange messages DEVICE GATEWAY Communicate with devices via MQTT and HTTP AUTHENTICATION AUTHORIZATION Secure with mutual authentication and encryption RULES ENGINE Transform messages based on rules and route to AWS Services AWS Services - - - - - 3P Services DEVICE SHADOW Persistent thing state during intermittent connections APPLICATIONS AWS IoT API DEVICE REGISTRY Identity and Management of your things
  • 4. In this session, we are going to dive deep RULES ENGINE Transform messages based on rules and route to AWS Services DEVICE SHADOW Persistent thing state during intermittent connections
  • 5. An Example: Connected Vacuum Cleaner Sweeps (duh!) Reports its state via events: • power, battery • status (DOCKED, RUNNING), • bin.lastEmptied, • bin.used, • firmware version, • filter.lastChanged, • filter.usageMinutes, • next run time Mobile Phone can • Initiate “Sweep” • Receives Push Notifications • Show Current State • Track History of Cleans • Track Path and Uncleaned Areas • Initiate Firmware Updates Wi-Fi Connected Vacuum Cleaner Mobile App to Control the Device
  • 6. AWS IoT Rules Engine Basics SELECT * FROM ‘things/thing-2/color’ WHERE color = ‘red’ Rule Name Description SQL Statement Array of Actions AWS Services, Native
  • 7. Simple & Familiar Syntax - SQL Statement to define topic filter - Optional WHERE clause - Advanced JSON support Functions improve signal : noise - String manipulation (regex support) - Mathematical operations - Context based helper functions - Crypto support - UUID, Timestamp, rand, etc. AWS IoT Rules Engine Basics SELECT * FROM ‘things/thing-2/color’ WHERE color = ‘red’
  • 8. AWS IoT Rules Engine’s Flexibility SELECT *, clientId() as MQTTClientId FROM 'one/rule' WHERE startsWith(topic(2), ’Vac123') AND (state = ‘SWEEP' OR bin.size < 30)", "actions": [{ "republish": { "topic": "controllers/${substring(topic(3), 3, 5)}", }]
  • 9. AWS IoT – SQL Reference SELECT DATA FROM TOPIC WHERE FILTER
  • 10. AWS IoT Rules Engine – Format { "sql":"SELECT 'IDLE' AS status FROM 'vacuum/+/events' WHERE event = 'COMPLETE'", "actions": [ { "dynamoDB": { "tableName":"vaccum-status", "hashKeyField":"vacuum_id", "hashKeyValue":"${topic(2)}", "payloadField":"statusDocument", "roleArn":"arn:aws:iam::77777:role/rules_action_ddb" } } ] }
  • 11. AWS IoT – SQL Reference SELECT DATA FROM TOPIC WHERE FILTER • Like scanning a database table • Default source is an MQTT topic EXAMPLES: • FROM mqtt(‘my/topic’) • FROM mqtt(‘my/wildcard/+/topic’) • FROM (‘my/topic’)
  • 12. AWS IoT – SQL Reference SELECT DATA FROM TOPIC WHERE FILTER • Properties from the JSON Object in the payload • “.” Operator • “..” Operator • “*” Operator • Apply functions to attribute value
  • 13. AWS IoT – SQL Reference SELECT DATA FROM… • SELECT * • SELECT deviceid, temp • SELECT coords.latitude • SELECT a.another_level.b • Returns {“b” : 3} • SELECT a..b • Returns {“b” : 3} { “deviceid” : “iot123”, “temp” : 54, “humidity” : 32, “coords” : { “latitude” : 47.615694, “longitude” : -122.3359976 }, “a” : { “another_level” : { {“b” : 3}, {“b” : 5} }} } SAMPLE PAYLOAD
  • 14. AWS IoT – SQL Reference SELECT DATA FROM… • SELECT deviceid AS client • SELECT md5(deviceid) AS hashed_id Substitution Templates • ${expression} • ${topic() - md5(deviceid)} • ${deviceid - temp} { “deviceid” : “iot123”, “temp” : 54, “humidity” : 32, “coords” : { “latitude” : 47.615694, “longitude” : -122.3359976 }, “a” : { “another_level” : { {“b” : 3}, {“b” : 5} }} } SAMPLE PAYLOAD
  • 15. AWS IoT – SQL Reference SELECT DATA FROM TOPIC WHERE FILTER Token Meaning Example = Equal, comparison color = 'red' <> Not Equal, comparison color <> 'red' AND Logical AND color = 'red' AND siren = 'on' OR Logical OR color = 'red' OR siren = 'on' () Parenthesis, grouping color = 'red' AND (siren = 'on' OR isTest) + Addition, arithmetic 5 + 3 - Substitution, arithmetic 5 - 4 / Division, arithmetic 8 / 2
  • 16. AWS IoT – SQL Reference SELECT DATA FROM TOPIC WHERE FILTER Token Meaning Example < Less than, comparison color = 'red' <= Less than or equal color <> 'red' > Greater than, comparison color = 'red' AND siren = 'on' >= Greater than or equal color = 'red' OR siren = 'on' CASE … WHEN … THEN … ELSE … END Case statement CASE location WHEN 'home’ THEN 'off' WHEN 'work’ THEN 'on' ELSE 'silent' END
  • 17. AWS IoT – SQL Reference SELECT DATA FROM TOPIC WHERE FILTER • Properties from the JSON Object in the payload • “.” Operator • “..” Operator • “*” Operator • Apply functions to attribute value
  • 18. AWS IoT Rules Engine Actions RULES ENGINE Transform messages based on rules and route to AWS Services AWS Services - - - - - 3P Services AWS Services - - - - - 3P Services
  • 19. 1. AWS Services (Direct Integration) Rules Engine Actions AWS IoT Rules Engine AWS Lambda Amazon SNS Amazon SQS Amazon S3 Amazon Kinesis Amazon DynamoDB Amazon RDS Amazon Redshift Amazon Glacier Amazon EC2 3. External Endpoints (via Lambda and SNS) Rules Engine connects AWS IoT to External Endpoints and AWS Services. 2. Rest of AWS (via Amazon Kinesis, AWS Lambda, Amazon S3, and more)
  • 20. AWS IoT Rules Engine Rules Engine evaluates inbound messages published into AWS IoT, transforms and delivers to the appropriate endpoint based on business rules. External endpoints can be reached via Lambda and Amazon Simple Notification Service (Amazon SNS). Invoke a Lambda function Put object in an S3 bucket Insert, Update, Read from a DynamoDB table Publish to an SNS Topic or Endpoint Publish to an Amazon Kinesis stream Actions Publish to Amazon Kinesis Firehose Republish to AWS IoT
  • 21. AWS IoT to AWS Lambda to and External Endpoint Lambda Function Rules Engine PolicyPrivate Key & Certificate Thing/Device Rule SDK AWS IoT AWS Services Execution Role Policy External Endpoint Permission Select * from ‘iotbutton/+’ Action
  • 22. AWS IoT to Amazon DynamoDB to Dashboard DynamoDB Table Rules Engine PolicyPrivate Key & Certificate Thing/Device Rule SDK AWS IoT AWS Services Policy Dashboard IAM Role Select * from ‘iotbutton/+’ Action DynamoDB S3 Website
  • 23. AWS IoT Rules Engine for Machine Learning Anomaly Detection Amazon Machine Learning can feed predictive evaluation criteria to the Rules Engine Continuous Improvement Around Predication Continuously look for outliers and re-calibrate the Amazon Machine Learning models Send to S3 Amazon Machine Learning Re-Train S3
  • 24. AWS IoT Rules Engine & Stream Data N:1 Inbound Streams of Sensor Data (Signal to Noise Reduction) Rules Engine filters, transforms sensor data then sends aggregate to Amazon Kinesis Amazon Kinesis Streams to Enterprise Applications Simultaneously stream processed data to databases, applications, other AWS Services Ordered Stream Amazon Kinesis
  • 25. In this session, we are going to dive deep RULES ENGINE Transform messages based on rules and route to AWS Services DEVICE SHADOW Persistent thing state during intermittent connections
  • 26. AWS IoT Device Shadow Shadow Virtual representation of your device in the cloud • Device State • desired • reported • Device metadata • Sensors • Version • clientToken • timestamp
  • 27. AWS IoT Shadow Flow Shadow Device SDK 1. Device Publishes Current State 2. Persist JSON Data Store 3. App requests device’s current state 4. App requests change the state 5. Device Shadow sync’s updated state 6. Device Publishes Current State 7. Device Shadow confirms state change AWS IoT
  • 28. AWS IoT Device Shadow Topics (MQTT) Thing SDK (C-SDK, JS-SDK) makes it easy for you build shadow functionality into your device so it can automatically synchronize the state with the device. AWS IoT Thing Shadow UPDATE: $aws/things/{thingName}/shadow/update DELTA: $aws/things/{thingName}/shadow/update/delta GET: $aws/things/{thingName}/shadow/get DELETE: $aws/things/{thingName}/shadow/delete Sensor Reported Desired Delta LED1 RED YELLOW LED1 = Yellow TEMP = 60F ACCEL X=1,Y=5,Z=4 X=1,Y=5,Z=4 TEMP 83F 60F
  • 29. Thing Shadow – Document Format { “state”: { “desired” : { “color”: “RED”, “sequence” : [ “RED”, “GREEN”, “BLUE”] }, “reported” : { “color” : “GREEN” } } “metadata” : { “desired” : { “color” : { “timestamp” : 12345 }, “sequence” : { “timestamp” : 12345 } }, }, “version” : 10, “clientToken” : “Unique-client-token”, “timestamp” : 123456 }
  • 31.
  • 32.
  • 33. Automatically clean when lights go off (night time) desired: { “status”: “RUNNING” } shadow/update update/accepted Republish vacuum/shadow/update vacuum/update/delta reported: { “AmbientLightValue”: 55 } Rules Engine Shadow Shadow One sensor automatically triggering the other device! Select * from $/update/accepted where AmbientLightValue <100
  • 34. Automatically clean when lights go off (night time) desired: { “status”: “RUNNING” } shadow/update update/accepted Republish vacuum/shadow/update vacuum/update/delta reported: { “AmbientLightValue”: 55 } Rules Engine Shadow Shadow One sensor automatically triggering the other device! Select * from $/update/accepted where AmbientLightValue <100
  • 35. Turn Off Automatic Cleaning At Night or Trigger Manually using the Mobile App Android App UpdateThingShadow Desired: { “status”: “RUNNING” } $aws/things/light/update $a/vacuum/update/delta Shadow Shadow
  • 36. AWS IoT DEVICE SDK Set of client libraries to connect, authenticate and exchange messages DEVICE GATEWAY Communicate with devices via MQTT and HTTP AUTHENTICATION AUTHORIZATION Secure with mutual authentication and encryption RULES ENGINE Transform messages based on rules and route to AWS Services AWS Services - - - - - 3P Services DEVICE SHADOW Persistent thing state during intermittent connections APPLICATIONS AWS IoT API DEVICE REGISTRY Identity and Management of your things