Building Better IoT Applications without Servers

49
Building better IoT Applications without Servers Ian Massingham Technology Evangelist, AWS IanMmmm

Transcript of Building Better IoT Applications without Servers

Page 1: Building Better IoT Applications without Servers

Building better IoT Applications without Servers

Ian Massingham Technology Evangelist, AWS

IanMmmm

Page 2: Building Better IoT Applications without Servers

Development, It’s fun

Page 3: Building Better IoT Applications without Servers

What’s hard (and probably not fun)

about running applications?

Page 4: Building Better IoT Applications without Servers

Deployment

Page 5: Building Better IoT Applications without Servers

Operations

Page 6: Building Better IoT Applications without Servers

Scaling

Page 7: Building Better IoT Applications without Servers

Security

Page 8: Building Better IoT Applications without Servers

Cost Optimisation

Page 9: Building Better IoT Applications without Servers

Lifecycle Management

Page 10: Building Better IoT Applications without Servers

Why Serverless?

Page 11: Building Better IoT Applications without Servers

It helps to solve a lot of these issues

Page 12: Building Better IoT Applications without Servers

One implementation: AWS Lambda

(plus a few other bits & pieces)

Page 13: Building Better IoT Applications without Servers

How do you apply these techniques to IoT?

Page 14: Building Better IoT Applications without Servers

Before we get to that

Page 15: Building Better IoT Applications without Servers

Other problems you need to solve

Page 16: Building Better IoT Applications without Servers

Device connectivity. It might be intermittent

Page 17: Building Better IoT Applications without Servers

Authentication & Authorisation

Page 18: Building Better IoT Applications without Servers

Device Registration

Page 19: Building Better IoT Applications without Servers

Security & cryptographic materials handling

Page 20: Building Better IoT Applications without Servers

Deploying/scaling/updating your Business/App Logic

Page 21: Building Better IoT Applications without Servers

Persisting Device Data (with the right characteristics)

Page 22: Building Better IoT Applications without Servers

(Predictive) Analytics/Visualisation

Page 23: Building Better IoT Applications without Servers

Building on platforms helps

Page 24: Building Better IoT Applications without Servers

AWS IoT

Page 25: Building Better IoT Applications without Servers

So don’t build a platform, unless you’re building a platform. In

which case, fine, build a platform.

Page 26: Building Better IoT Applications without Servers

Building ‘Hello World’ (for IoT Developers)

Page 27: Building Better IoT Applications without Servers
Page 28: Building Better IoT Applications without Servers

Turns out, developers are creative

Page 29: Building Better IoT Applications without Servers

Sassy Ping PongScore Keeper

Source: https://www.hackster.io/youngd/ping-pong-showdown-eabaed

Page 30: Building Better IoT Applications without Servers

Slack-powered Doorbell

Source: www.theatlantic.com/notes/2016/07/make-every-week-2-a-silent-slack-powered-doorbell/490880/

Page 31: Building Better IoT Applications without Servers

Source: http://www.andrewmcgill.me/2016/08/19/make-every-week-sweetgreen-salad-button.html

EmergencySweet Green Ordering

Page 32: Building Better IoT Applications without Servers

Push a button to get directions to the right meal within your budget. (Integrate time of day, weather, Google Directions, Yelp, and Stripe)

Source: https://medium.com/@_adeel/nerding-out-with-the-amazon-iot-button-84a6e14b6b28#.ekd5hsnez

Page 33: Building Better IoT Applications without Servers

How does it work?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 a Kinesis stream

Kinesis Firehose > Redshift

Republish to AWS IoT

AWS IoT

Page 34: Building Better IoT Applications without Servers

All with no servers, of course

Page 35: Building Better IoT Applications without Servers

But wait, I live in the UK and I want to do this. Right now!

Page 36: Building Better IoT Applications without Servers

HARDWARE YOU WILL (& MIGHT) NEED

• A Raspberry Pi

• Electronics Kit • Try the SunFounder 37 modules Sensor Kit v2.0 for

Raspberry Pi 3, 2, Model B+ with 40-Pin GPIO Extension Board & Jump Wires

• http://www.amazon.co.uk/dp/B014PF05ZA • Example tutorial

• Raspberry Pi Sense Hat (optional fun) • https://www.raspberrypi.org/products/sense-hat/

Page 37: Building Better IoT Applications without Servers

SETTING UP FOR GPIO/SENSE HAT

Your own electronics/sensor build C (for embedded C)

http://wiringpi.com Python Wrapper Module for WiringPI

https://github.com/WiringPi/WiringPi-Python

For the Sense Hat Python Module

https://github.com/RPi-Distro/python-sense-hat

Page 38: Building Better IoT Applications without Servers

SETTING UP FOR AWS IOT

Use the AWS Console to create your device

Download the required crypto materials & save the C header file contents with your endpoint, cert, and key details

Download & set up your chosen AWS IoT SDK Get them at : https://aws.amazon.com/iot/sdk/

Building the C SDK on the Raspberry Pi requires the CppUTest library from: https://github.com/cpputest/cpputest/releases/tag/v3.6

Get started with the sample applications that come with the AWS SDKs

Page 39: Building Better IoT Applications without Servers

EXAMPLES & DEMOS

Emulating the AWS IoT Button (C++) https://github.com/ianmas-aws/iot-button-emulator

Controlling the Sense Hat via AWS IoT Device Shadow (Python) https://github.com/ianmas-aws/PiPyIoT

Page 40: Building Better IoT Applications without Servers
Page 41: Building Better IoT Applications without Servers

Go Build, Have Fun

Ian Massingham Technology Evangelist, AWS

IanMmmm

Page 42: Building Better IoT Applications without Servers

1.

Page 43: Building Better IoT Applications without Servers

2.

Page 44: Building Better IoT Applications without Servers

2.

Page 45: Building Better IoT Applications without Servers

3.

Page 46: Building Better IoT Applications without Servers

4.

Page 47: Building Better IoT Applications without Servers

Alert Someone: AWS IoT to AWS Lambda to SNS

Lambda Function

AWS IoT Rules Engine

PolicyPrivate Key & Certificate

Button

RuleSDK

AWS IoT

AWS Services

Execution Role Policy

SNS Topic

PermissionAction

SNS Topic Subscription

Rule: “Select * from ‘iotbutton/+’

Event Source

Function

SMS or Email

Page 48: Building Better IoT Applications without Servers

Count items or Track Usage: AWS IoT to DynamoDB to Dashboard

DynamoDB

Rules Engine

Dashboard

S3 Website

Lambda Function

PolicyPrivate Key & Certificate

Button

RuleSDK

AWS IoT

AWS Services

Execution Role

PolicyPermissionAction

Rule: “Select * from ‘iotbutton/+’

Event Source

FunctionDynamoDB API Gateway

Page 49: Building Better IoT Applications without Servers

Start or Stop Something : AWS IoT to AWS Lambda to an External Endpoint

Lambda Function

Rules Engine

PolicyPrivate Key & Certificate

Thing/Device

RuleSDK

AWS IoT AWS Services

Execution Role Policy

External Endpoint

Permission

Rule: Select * from ‘iotbutton/+’

Action

External API

LifX API