Cloud Tutorial: AWS IoT CSE 521S Fall Sep. 17, 2020 Ruixuan - - PowerPoint PPT Presentation

cloud tutorial aws iot
SMART_READER_LITE
LIVE PREVIEW

Cloud Tutorial: AWS IoT CSE 521S Fall Sep. 17, 2020 Ruixuan - - PowerPoint PPT Presentation

Cloud Tutorial: AWS IoT 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 q


slide-1
SLIDE 1

Cloud Tutorial: AWS IoT

CSE 521S Fall

  • Sep. 17, 2020

Ruixuan (Corey) Dai

slide-2
SLIDE 2

XaaS: Basics in Cloud Computing

slide-3
SLIDE 3

Cloud Computing

9/17/20 3

Ø Cloud computing provides shared pool of configurable computing resource to end users on demand Ø Three service models

q IaaS (Infrastructure as a Service): virtual machines, storage,

network …

q PaaS (Platform as a Service): execution runtime, middleware,

web server, database, development tool …

q SaaS (Software as a Service): email, virtual desktop, games …

slide-4
SLIDE 4

Cloud Services: On-premise Software

Ø Traditional

Ø installed and runs on personal computer Ø You Manage and Deploy

q Hardware q OS q Software

Ø Example

q This presentation

9/17/20 4

APP Data Runtime Middleware OS Virtualization Server Storage Network You Manage

slide-5
SLIDE 5

Infrastructure as a Service (IaaS)

Ø IaaS

q "physical server box” q Virtual Machine

  • Memory
  • Storage
  • CPU
  • Network

Ø Example

q AWS EC2 q AWS EFS

Ø Use case

q Build up you VM cluster

9/17/20 5

You Manage APP Data Runtime Middleware OS Virtualization Server Storage Network Service Provider Manages

Web Service

slide-6
SLIDE 6

Platform as a Service (PaaS)

Ø PaaS

q You get a framework q Host Application q T

  • ols

Ø Example

q AWS IoT

Ø Use case

q Build up you’re smart A/C

controller

9/17/20 6

You Manage Service Provider Manages APP Data Runtime Middleware OS Virtualization Server Storage Network

slide-7
SLIDE 7

PaaS Example: AWS IoT

9/17/20 7

Tools Framework

The essence is MESSAGING MIDDLEWARE Send messages between sensors and servers…

slide-8
SLIDE 8

Software as a Service (SaaS)

Ø SaaS

q You get a whole solution

Ø Example

q Gmail q Dropbox q Office365

9/17/20 8

Service Provider Manages APP Data Runtime Middleware OS Virtualization Server Storage Network

slide-9
SLIDE 9

XaaS: A Recap

9/17/20 9

APP Data Runtime Middleware OS Virtualization Server Storage Network You Manage You Manage APP Data Runtime Middleware OS Virtualization Server Storage Network Service Provider Manages You Manage Service Provider Manages APP Data Runtime Middleware OS Virtualization Server Storage Network Service Provider Manages APP Data Runtime Middleware OS Virtualization Server Storage Network

On-Premise IaaS PaaS SaaS

slide-10
SLIDE 10

Tutorial: Hello! AWS IoT!!

slide-11
SLIDE 11

Internet-of-Things

9/17/20 11

Ø Internet-of-Things

q Devices

  • Different Types

§ Sensors, actuators

q Data and Command

  • Sensing the world
  • Give Response

q Challenge

  • United: Connected + Communication
  • Smart: Data Analytics + Strategy

Source: https://aws.amazon.com/iot-platform/ http://www.brain-smart.net/smart-brain-health-blog/page/2/#axzz4W4oSp8a6

slide-12
SLIDE 12

Solution: AWS IoT

9/17/20 12

United: Connect + Communication Smart: Other Cloud Service Data Storage Machine Learning

Source: https://aws.amazon.com/iot-platform/

Stated: “Thing Shadow”

slide-13
SLIDE 13

Tutorial: Hello AWS IoT!

9/17/20 13 Source: https://aws.amazon.com/iot-platform/

Publish to a topic Amazon SNS Forward Subscribe to a topic Temperature sensor Period: 5s (0.2Hz) Message middleware

Ø Key concepts:

q Publisher (e.g. Sensor), Subscriber (e.g. Server), Topic

  • Topic is used to identify the message.

Ø Not a traditional “peer-to-peer” communication.

slide-14
SLIDE 14

Basic Interact: Subscribe/Publish

9/17/20 14

Ø You can define your own Topic (Twitter Account) Ø Subscriber can receive the message you published to your topic

Follow “subscribe” a “Topic” I am going to publish a tweet. “Today is beautiful ” Twitter account Tweet “Publish” Received message from Trump: “Today is beautiful” Subscriber Publisher

slide-15
SLIDE 15

Resources

Ø Amazon IoT

q http://docs.aws.amazon.com/iot/latest/developerguide/what-is-

aws-iot.html

Ø Raspberry Pi

q https://www.raspberrypi.org/

Ø Resource list for course projects

q http://cps.cse.wustl.edu/index.php/List_of_Projects

Ø Apply for $40 credits for Amazon AWS

q https://aws.amazon.com/education/awseducate/apply/

15

slide-16
SLIDE 16

Get into AWS Manage Console

Ø Create your own AWS account Ø Sign In IoT Manage Console

q https://aws.amazon.com/iot/

9/17/20 16

slide-17
SLIDE 17

Step 1: Create a Virtual "Thing”

9/17/20 17

AWS IoT Virtual “Thing” / Shadow

Ø Virtual “Thing”: a virtual copy of your thing

q 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

q Shadow is a special topic in AWS IoT

Ø Certificates and policy

q Authentication, Security q Permission and roles A “Dashboard” to show some info Certificates -> your ID Policy -> your permission book

slide-18
SLIDE 18

Create a thing

Ø 1. AWS IoT Menu

  • Things è Create

Ø 2. Give a name

9/17/20 18

slide-19
SLIDE 19

19

slide-20
SLIDE 20

20

slide-21
SLIDE 21

21

The keys and cert will be used later

slide-22
SLIDE 22

Create Policy

Ø A policy is attached to a key/cert

q It tells what this key/cert can do

22

slide-23
SLIDE 23

23

Here, we grant it all permissions for demo!

slide-24
SLIDE 24

24

This is the policy you created

slide-25
SLIDE 25

Attach Policy

Ø Attach Policy to the key/cert

q A policy tells what this key/cert can do

25

Click the cert you just created

slide-26
SLIDE 26

26

slide-27
SLIDE 27

27

slide-28
SLIDE 28

28

Now, you have a virtual thing on AWS!

slide-29
SLIDE 29

AWS Things Summary

29

q Certificate: authenticate the device q Policy: define the roles/permissions of the

certificate

q Virtual copy of the thing (Shadow): Store/retrieve

some information

slide-30
SLIDE 30

Let’s test it online!

slide-31
SLIDE 31

Basic Interact: Publish to the “Shadow”

Ø Get your “Shadow”

q In your Thing Page

9/17/20 31

Shadow Topic Shadow is a special topic

slide-32
SLIDE 32

Find your “Shadow” Topic

Ø Topic: can be seen as the “address”

9/17/20 32 https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html?icmpid=docs_iot_console

Shadow Topic: $aws/things/cse521/shadow/update

slide-33
SLIDE 33

Ø Using Embedded Test Client to Test

q In AWS IoT Page

9/17/20 33

Your Shadow Topic Topic Message

slide-34
SLIDE 34

Shadow Message

{ "state": { "reported":{ "welcome": "CSE521s", "time":"13:45", "temperature":"25"} }, "message": "Hello from CSE521s console"}

34

A Shadow Message is a JSON object. Shadow message has strict formats. Please see https://docs.aws.amazon.com/iot/latest/developerguide/device- shadow-document-syntax.html

slide-35
SLIDE 35

Update Shadow

Ø In your “Thing” Page

35

slide-36
SLIDE 36

Basic Interact: Subscribe/Publish

9/17/20 36

Ø You can define your own Topic Ø Once you have a subscriber that is subscribed to the topic, the subscriber can receive the message

slide-37
SLIDE 37

Temperature sensor Period: 5s (0.2Hz)

Step 2: Connect a “Physical” Device

9/17/20 37

AWS IoT Virtual “Thing” / Shadow Attach Certificate Policy Copy AWS SDK Client AWS IoT SDK

slide-38
SLIDE 38

Connect your Device

Ø Copy certificates to your physical things

q Downloaded before!

Ø Choose your AWS SDK (support MQTT)

q Node JS q Python (pip install AWSIoTPythonSDK) q Java q …

Ø Set up your client with SDK and the certificates

9/17/20 38

slide-39
SLIDE 39

Some Notes

Ø 1. Copy the certificates/keys to your real thing Ø 2. You will need the endpoint and port (8883) Ø 3. Set up your configuration of the code with SDK

9/17/20 39

Host(Endpoint) Change your code accordingly!

slide-40
SLIDE 40

SDK and Demo Codes

Ø https://github.com/aws/aws-iot-device-sdk-python Ø https://github.com/aws/aws-iot-device-sdk- python/blob/master/samples/basicPubSub/basicPubSub.py

40

slide-41
SLIDE 41

More: Rule Engine, Link with SNS services

Ø Simple Notification Service

9/17/20 41

Publish Amazon SNS AWS IoT Virtual “Thing” / Shadow Forward Topic: CSE521_Tutorial Subscribe Subscribe

AWS

EC2 t2.micro

slide-42
SLIDE 42

Create a Rule in Amazon IoT

Ø Add a query to filter your interesting topic (event) Ø Add an Action:

q Forward this message to SNS q Specify Dest ARN q Enable Rule

9/17/20 42

slide-43
SLIDE 43

Notification on SMS & Email

9/17/20 43

slide-44
SLIDE 44

One More Thing: Account Security

Ø DON’T UPLOADYOUR KEY PUBLICLY!!!

9/17/20 44

Time to Open Source!

Source: WeChat Subscriptions: 西乔《神秘的程序员们 39》 Geek Life Chpt 39.

slide-45
SLIDE 45

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

slide-46
SLIDE 46

Some project examples

Ø Gesture recognition with smartwatch

q Recognize the specific gesture to control the light

Ø Smart pet feeder

q Food dispenser with schedules and smart control

Ø Smart mirror

q Show personalized info in the mirror

46

Sensing, Connecting, Smart If you have any question about the project, feel free to send me an Email

slide-47
SLIDE 47

Thanks!

Ruixuan Dai