Cloud Tutorial: Aws Iot: Cse 521S Fall Sep. 17, 2020 Ruixuan (Corey) Dai
Cloud Tutorial: Aws Iot: Cse 521S Fall Sep. 17, 2020 Ruixuan (Corey) Dai
Cloud Tutorial: Aws Iot: Cse 521S Fall Sep. 17, 2020 Ruixuan (Corey) Dai
CSE 521S
Fall Sep.
17, 2020
Ruixuan
(Corey) Dai
XaaS: Basics in Cloud Computing
Cloud Computing
Cloud computing provides shared pool of configurable
computing resource to end users on demand
Three service models
IaaS (Infrastructure as a Service): virtual machines, storage,
network …
9/17/20 3
Cloud Services: On-premise Software
Traditiona APP
l
installed and runs on Data
personal computer Runtime
You Manage
Deploy
OS
Hardware
OS Virtualization
Software
Server
Example
This presentation Storage
Network
9/17/20 4
Infrastructure as a Service (IaaS)
Iaa
APP
S "physical server box” Web
Virtual Machine Service Data
You Manage
• Memory
Runtime
• Storage
• CPU Middleware
• Network
OS
Example
You Manage
APP
You get a framework
Host Data
Application Runtime
Tools
Middleware
9/17/20 6
PaaS Example: AWS IoT
Tools
Framewor
k The essence is MESSAGING MIDDLEWARE
9/17/20 Send messages between sensors and servers… 7
Software as a Service (SaaS)
SaaS APP
You get a whole solution
Data
Exampl Middleware
e
OS
Gmail
Drop Virtualization
box
Server
Offic
e365 Storage
Network
9/17/20 8
XaaS: A Recap
On-Premise IaaS PaaS SaaS
You Manage
APP APP APP APP
You Manage
Runtime Runtime Runtime Runtime
OS OS OS OS
Service Provider Manages
Virtualization Virtualization Virtualization Virtualization
Challenge
• United:
Connected +
Communication
• Smart: Data
9/17/20 Analytics + Source: https://aws.amazon.com/iot-platform/ 11
http://www.brain-smart.net/smart-brain-health-blog/page/2/#axzz4W4oSp8a6
Solution: AWS IoT
Amazon SNS
Subscribe to a topic
Temperature sensor
Period: 5s (0.2Hz)
Message middleware
9/17/20 Source: https://aws.amazon.com/iot-platform/ 13
Basic Interact: Subscribe/Publish
You can define your own Topic (Twitter Account)
Subscriber can receive the message you published to your
topic
I am going to
publish a
tweet.
“Today is
Tw beautiful ”
“P ee
ow i be” ub t
ll r lis
F o u b sc h”
“s Twitter account
a “Topic”
Received message
Subscriber from Trump:
“Today is beautiful”
Publisher
9/17/20 14
Resources
Amazon IoT
http://docs.aws.amazon.com/iot/latest/developerguide/what-is-
aws-iot.html
Raspberry Pi
https://www.raspberrypi.org/
15
Get into AWS Manage Console
Create your own AWS account
Sign In IoT Manage Console
https://aws.amazon.com/iot/
9/17/20 16
Step 1: Create a Virtual "Thing”
Virtual “Thing”: a virtual copy of your thing
A Thing in AWS IoT has a “shadow”
• a JSON document that is used to store and retrieve current
state information for a device.
E.g. Battery level, Connectivity, data
A “Dashboard” to show some info
Shadow is a special topic in AWS IoT
9/17/20 17
Create a thing
1. AWS IoT Menu
• Things Create
2. Give a name
9/17/20 18
19
20
The keys and cert will be used
later
21
Create Policy
A policy is attached to a key/cert
It tells what this key/cert can do
22
Here, we grant it all permissions for demo!
23
This is the policy you created
24
Attach Policy
Attach Policy to the key/cert
A policy tells what this key/cert can do
25
26
27
Now, you have a virtual thing on AWS!
28
AWS Things Summary
Certificate: authenticate the device
Policy: define the roles/permissions of the
certificate
Virtual copy of the thing (Shadow): Store/retrieve
some information
29
Let’s test it online!
Basic Interact: Publish to the “Shadow”
Get your “Shadow” Shadow is a special topic
In your Thing Page
Shadow Topic
9/17/20 31
Find your “Shadow” Topic
Topic: can be seen as the “address”
Shadow Topic:
$aws/things/cse521/shadow/update
9/17/20 https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html?icmpid=docs_iot_console 32
Using Embedded Test Client to Test Your Shadow Topic
In AWS IoT Page
Topic Message
9/17/20 33
Shadow Message
{ "state": {
"reported":{
"welcome": "CSE521s",
"time":"13:45",
"temperature":"25"}
},
"message": "Hello from CSE521s
console"}
35
Basic Interact: Subscribe/Publish
You can define your own Topic
Once you have a subscriber that is subscribed to the topic,
the subscriber can receive the message
9/17/20 36
Step 2: Connect a “Physical” Device
Certificate
Temperature senso r
Period: 5s (0.2Hz)
Copy Policy
9/17/20 37
Connect your Device
Copy certificates to your physical things
Downloaded before!
9/17/20 38
Some Notes
1. Copy the certificates/keys to your real thing
Host(Endpoint)
3. Set up your configuration of the code with SDK
40
More: Rule Engine, Link with SNS services
Simple Notification
Service AWS IoT
Publish
Virtual “Thing”
EC2 t2.micro
/ Shadow
AWS
Forward
Subscribe
Topic:
CSE521_Tutoria
l
Add an Action:
Forward this message to SNS
Specify Dest ARN
Enable Rule
9/17/20 42
Notification on SMS & Email
9/17/20 43
One More Thing: Account Security
DON’T UPLOAD YOUR KEY
PUBLICLY!!!
9/17/20 44
Source: WeChat Subscriptions: 西乔《神秘的程序员们 39 》 Geek Life Chpt
What if… $50,000 AWS Bill!
9/17/20 45
Source: https://www.quora.com/My-AWS-account-was-hacked-and-I-have-a-50-000-bill-how-can-I-reduce-the-amount-I-need-to-pay
Some project examples
Gesture recognition with smartwatch
Recognize the specific gesture to control the light
Smart mirror
Show personalized info in the mirror
Ruixuan Dai