서버리스 IoT 백엔드 개발 및 구현 사례 : 윤석찬 (AWS 테크에반젤리스트)

Preview:

Citation preview

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

••

••

••

Unlimited Storage – Memory

Unlimited Compute – Logic

Cloud offers

Dr. Werner Vogels, Amazon.com CTOre:Invent 2015 Keynote

COMPUTE SERVICE

EVENT-DRIVEN

AWSLambda

Application-tier at Scale

디바이스 SDK클라이언트 인증 및 연결,

메시지 교환을 위한개발도구

디바이스 게이트웨이MQTT 및 HTTP 기반

디바이스 통신

보안 및 인증고급 인증 및 암호화를

통한 보안 제공

RULES ENGINE장치메시지를 규칙에 따라AWS 서비스와 연계 동작

AWS 서비스- - - - -

서드파티 서비스

DEVICE SHADOW네트웍 단절에도 응답하는

가상 장치

애플리케이션

AWS IoT API

디바이스 레지스트리IoT 장치 등록 및 관리

SubscribersPublishers

•o

o

o

{"Version": "2012-10-17","Statement": [

{

"Effect": "Allow","Action": ["iot:Publish"],

"Resource": ["arn:aws:iot:us-east-1::topic/foo"]

},{

"Effect": "Allow","Action": ["iot:Subscribe"],

"Resource": ["arn:aws:iot:us-east-

1::topicfilter/foo/bar/*"]}]}

•ü

ü

•ü

ü

ü

ü

SELECT * FROM ‘things/thing-2/color’ WHERE color = ‘red’

{

"SELECT *, clientId() as MQTTClientId FROM 'room/ac/+' WHERE temperature > 30","actions": [{

”sns": {"roleArn": "arn:aws:iam::123456789012:role/SNSPutRole","topicArn": "arn:aws:sns:us-

east-1:123456789012:TempWarningNotification"}

]}

AWS Lambda 함수 실행

S3 버킷에 객체 저장

DynamoDB 테이블에 데이터추가/변경

SNS 토픽으로 푸시 메시지

Amazon Kinesis 실시간 스트림

동작 실행

Amazon Kinesis Firehose 전달

AWS IoT에 전달

••••

{"state" : {

“desired" : {"lights": { "color": "RED" },"engine" : "ON"

},"reported" : {

"lights" : { "color": "GREEN" },"engine" : "ON"

},"delta" : {

"lights" : { "color": "RED" }}

},"version" : 10}

Thing

Mobile App

Shadow

••

•••

desired: {“status”: “RUNNING”

}

shadow/update update/accepted

Republish vacuum/shadow/update

vacuum/update/delta

reported: {“AmbientLightValue”: 55

}

Rules Engine

Shadow

ShadowSelect * from $/update/accepted where AmbientLightValue <100

C-SDK(Ideal for embedded

OS)

JS-SDK (Ideal for Embedded

Linux Platforms)

Arduino Library

(Arduino Yun)

Mobile SDK(Android and iOS)

üü

AWS IoT

DynamoDB 테이블: 전체 센서 데이터 받는 경우

데이터 확인: 모든 센서 데이터를 다 받는 경우

AWS IoT

Amazon CloudWatch

AWSCloudFormation

AmazonDynamoDB

Amazon ElastiCache

AmazonAurora

IoTshadow

Amazon API GatewayAWS Lambda

AmazonS3

Amazon Kinesis

AmazonSQS

Amazon SNS

AmazonQuicksight

Amazon ElasticSearch

AmazonMachineLearning

Amazon Redshift

Mobile

Beacon

Amazon echo

Window sensorPower Plug

Switch

Bulb

Doorlock

Gateway

Boiler

Siren

Camera

Mobile

Beacon

API Gateway Lambda

AWS IoT

RDS SNS

S3DynamoDB

Certification Policy Shadow Rule Engine

Alexa Skills Kit – KOLON Home Service

Amazon echo

Users

Skill Information

publishingAmazon Alexa Skill : Home IoT In Mode

Alexa Skill Kit

Model-intent-utterance

PublishingLambda ARN

TEST Skill

// DEVELOPER CONSOLE

Lambda RDS

Device Gateway

Device Shadow

AWS IoT

Amazon echo

Users

Lambda RDS

Device Gateway

DeviceShadow

AWS IoT

Beacon

SELECT * FROM '$aws/things/p100002201/shadow/update/accepted' WHERE state.reported.detail.beacon_loc > 10

Rule Engine Query

RuleEngine

Users

Lambda

RDS

SNS

S3

DynamoDB

Device Gateway

Device Shadow

AWS IoT

Mobile

API Gateway

PUT : ThingCtrlPUT : SecurityModePOST : SecurityMode ClearPUT : OutModePUT : Inmode

Restful API

RuleEngine

Door Sensor

def foo(input):quux = bar(input.baz)internalState.quux = quuxmysql_insert(quux)

def bar(input):# do workreturn result

Foo Bar

••

def handler(event, context):quux = Lambda.Invoke(

'bar', event['baz'])DynamoDB.PutItem(

'quux', quux)

def handler(event, context):# do workreturn result

Foo Bar

••

Monolithic/layered Microservices

••

App requestsover HTTPS

CRUDoperations

MQTT

CRUDoperations

MQTT

CloudWatch eventevery 5 minutes

Lambda runsfor 5 minutes

Amazon SQS queue

/register Checkcert

Robots toregister Queue

readerRegister

robot

Logging Lifecycle event

PermissionsCreate shadowDead letter queue

Robotcertificate+ signed timestamp

CA certificate

UnauthenticatedHTTPS

Robotcertificate

AuthenticatedMQTT

Request topicPresigned URL

Symmetricencryption key

Robotpublic key

Response topic

Presigned URL

Object encrypted withsymmetric key

HTTPS callto presigned URL

S3

KMS

Robotcertificate

S3bucket

+symmetric keyencrypted withrobot public key

Fleet of Sensors

OperatorAmazon SNS

AWSLambda

AWSIoT

AWSGreengrass

Core

•••••

AmazonDynamoDB

AWSLambda

AmazonRedshift

https://aws.amazon.com/ko/serverless/ https://aws.amazon.com/ko/iot/

http://bit.ly/awskr-feedback

Recommended