SlideShare una empresa de Scribd logo
1 de 39
Descargar para leer sin conexión
Hands-on with AWS IoT
Julien Simon
Principal Technical Evangelist
Amazon Web Services
julsimon@amazon.fr
@julsimon
Agenda
•  Overview of AWS IoT
•  Devices & SDKs, with a focus on the Arduino Yún
•  The MQTT protocol
•  Creating and securing “things”
•  Routing AWS IoT messages to other AWS services
•  Debugging AWS IoT applications
•  And lots of AWS CLI, yeah!
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
- - - - -
3rd party
DEVICE SHADOW
Persistent thing state
during intermittent
connections
APPLICATIONS
AWS IoT API
DEVICE REGISTRY
Identity and Management of
your things
*** NEW (April 7) : AWS IoT is now available in eu-central-1 (Frankfurt)
Devices & SDKs
Official AWS IoT Starter Kits
Software platforms supported by AWS IoT
•  Arduino: Arduino Yún platform
•  Node.js: ideal for Embedded Linux
•  C: ideal for embedded OS
Personal picture
Arduino Yún SDK
Arduino IDE and librairies
http://arduino.org/software
AWS IoT SDK
https://github.com/aws/aws-iot-
device-sdk-arduino-yun
Things
Requirements
•  Thing Registry
•  Secure Identity for Things
•  Secure Communications with Things
•  Fine-grained Authorization for:
–  Thing Management
–  Publish / Subscribe Access
–  AWS Service Access
Creating a thing
% aws iot create-thing --thing-name myThing
% aws iot describe-thing --thing-name myThing
% aws iot list-things
Creating a certificate and keys
% aws iot create-keys-and-certificate
--set-as-active
--certificate-pem-outfile cert.pem
--public-key-outfile publicKey.pem
--private-key-outfile privateKey.pem
*** NEW (April 11) : You can now use your own certificates
The AWS IoT root certificate, the thing certificate and the thing private key must
be installed on your device, e.g.
https://github.com/aws/aws-iot-device-sdk-arduino-yun
Creating a policy
% cat myPolicy.json
{
"Version": "2012-10-17",
"Statement": [{ "Effect": "Allow", "Action":["iot:*"],
"Resource": ["*"] }]
}
% aws iot create-policy
--policy-name PubSubToAnyTopic
--policy-document file://myPolicy.json
Assigning an identity to a Policy and a Thing
% aws iot attach-principal-policy
--policy-name PubSubToAnyTopic
--principal CERTIFICATE_ARN
% aws iot attach-thing-principal
--thing-name myThing
--principal CERTIFICATE_ARN
Arduino : connecting to AWS IoT
aws_iot_mqtt_client myClient;
if((rc = myClient.setup(AWS_IOT_CLIENT_ID)) == 0) {
// Load user configuration
if((rc = myClient.config(AWS_IOT_MQTT_HOST,
AWS_IOT_MQTT_PORT, AWS_IOT_ROOT_CA_PATH,
AWS_IOT_PRIVATE_KEY_PATH, AWS_IOT_CERTIFICATE_PATH)) == 0) {
if((rc = myClient.connect()) == 0) {
// We are connected
doSomethingUseful();
}
}
}
The MQTT protocol
MQTT Protocol
MQTTS vs HTTPS:
93x faster throughput
11.89x less battery to send
170.9x less battery to receive
50% less power to stay connected
8x less network overhead
Source:
http://stephendnicholas.com/archives/1217
•  OASIS standard protocol (v3.1.1)
•  Lightweight, transport protocol that is
useful for connected devices
•  Publish-subscribe with topics
•  MQTT is used on oil rigs, connected
trucks, and many more critical
applications
•  Until now, customers had to build,
maintain and scale a broker to use
MQTT with cloud applications
MQTT: device-to-device communication
mydevices/alert
MQTT: collect data from a device
mydevices/4
mydevices/4
MQTT: aggregate data from many devices
mydevices/#
mydevices/1
mydevices/2
mydevices/3
….
Amazon
DynamoDB
Applications
MQTT: update a device
mydevices/4
mydevices/4
MQTT: QoS 0 (at most once)
1
2
3
4
5
6
1,2,3,5,6
Publish QoS0
MQTT: QoS 1 (at least once)
1
2
3
4
5
4
1,2,3,4,5,6
6
PUBLISH QoS1
PUBLISH QoS1
PUBACK
MQTT.fx
http://mqttfx.jfx4ee.org/
Arduino : subscribing and publishing to a topic
if ((rc=myClient.subscribe(”myTopic", 1, msg_callback)) != 0)
{
Serial.println("Subscribe failed!");
Serial.println(rc);
}
if((rc = myClient.publish(”myTopic", msg, strlen(msg),
1, false)) != 0)
{
Serial.println("Publish failed!");
Serial.println(rc);
}
Arduino : callback for incoming messages
// Basic callback function that prints out the message
void msg_callback(char* src, int len) {
Serial.println("CALLBACK:");
for(int i = 0; i < len; i++) {
Serial.print(src[i]);
}
Serial.println("");
}
Rules
Granting AWS IoT access to AWS services
DynamoDB LambdaAmazon
Kinesis
Defining a trust policy for AWS IoT
% cat iot-role-trust.json
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"",
"Effect":"Allow",
"Principal":{
"Service":"iot.amazonaws.com"
},
"Action":"sts:AssumeRole"
}
]
}
Applying the trust policy to AWS IoT
% aws iam create-role --role-name my-iot-role
--assume-role-policy-document file://iot-role-trust.json
{
"Role": {
"AssumeRolePolicyDocument": {…},
"RoleId": "AROAJY7VZX5GEZ3Q7ILU4",
"CreateDate": "2016-03-19T12:07:03.904Z",
"RoleName": "my-iot-role",
"Path": "/",
"Arn": "arn:aws:iam::613904931467:role/my-iot-role"
}
}
1. AWS Services
(Direct Integration)
Rules Engine
Actions
AWS IoT Rules
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 connect AWS IoT to
External Endpoints and AWS
Services.
2. Rest of AWS
(via Amazon Kinesis, AWS
Lambda, Amazon S3, and
more)
*** NEW (March 16) : direct integration with Amazon Elasticsearch & CloudWatch
*** NEW (April 11) : direct integration with Amazon Machine Learning
AWS IoT Rules Engine
Rule
Name
Description
SQL Statement
Array of Actions
Simple & Familiar Syntax
-  SQL Statement to define topic filter
-  Optional WHERE clause
-  Advanced JSON support
Many functions available
-  String manipulation (regex support)
-  Mathematical operations
-  Crypto support
-  UUID, Timestamp, rand, etc.
Creating a rule to write to DynamoDB
% cat topic1-dynamodb-rule.json
{
"sql": "SELECT * FROM 'topic1'",
"ruleDisabled": false,
"actions": [{
"dynamoDB": {
"tableName": "iot-topic1-table",
"roleArn": "arn:aws:iam::613904931467:role/my-iot-role",
"hashKeyField": "deviceId",
"hashKeyValue": "${deviceId}",
"rangeKeyField": "timestamp",
"rangeKeyValue": "${timestamp()}"
}
}]
}
% aws iot create-topic-rule --rule-name topic1-dynamodb-rule
--topic-rule-payload file://topic1-dynamodb-rule.json
Debugging
How can you debug AWS IoT applications?
•  Testing with MQTT.fx (or a similar tool) is not enough
•  CloudWatch Logs: the only way to see what is happening
inside AWS IoT
–  Permission issue
–  Rule issue
–  Incorrect JSON message
–  Etc.
•  These logs are not enabled by default:
–  Define a policy allowing AWS IoT to access CloudWatch logs
–  Attach the policy to the AWS IoT role (same one as for external services)
Defining a policy for CloudWatch Logs
% cat iot-policy-logs.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:PutMetricFilter",
"logs:PutRetentionPolicy"
],
"Resource": [
"*"
]
}
]
}
Enabling CloudWatch Logs for AWS IoT
% aws iam create-policy
--policy-name my-iot-policy-logs --policy-document file://iot-policy-logs.json
{
"Policy": {
"PolicyName": "my-iot-policy-logs",
"CreateDate": "2016-03-19T12:24:16.072Z",
"AttachmentCount": 0,
"IsAttachable": true,
"PolicyId": "ANPAIK73XIV3QG5FF5TX6",
"DefaultVersionId": "v1",
"Path": "/",
"Arn": "arn:aws:iam::613904931467:policy/my-iot-policy-logs",
"UpdateDate": "2016-03-19T12:24:16.072Z"
}
}
% aws iam attach-role-policy --role-name my-iot-role
--policy-arn "arn:aws:iam::613904931467:policy/my-iot-policy-logs"
% aws iot set-logging-options
--logging-options-payload roleArn="arn:aws:iam::613904931467:role/my-iot-role",logLevel="INFO"
Demo : logging events in CloudWatch Logs
Thank You !
Julien Simon
julsimon@amazon.fr
@julsimon

Más contenido relacionado

La actualidad más candente

如何無痛上雲端? 以Elastic Beanstalk Java Container為例
如何無痛上雲端? 以Elastic Beanstalk Java Container為例如何無痛上雲端? 以Elastic Beanstalk Java Container為例
如何無痛上雲端? 以Elastic Beanstalk Java Container為例
Yuen-Kuei Hsueh
 

La actualidad más candente (20)

Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC...
 Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC... Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC...
Using Amazon CloudWatch Events, AWS Lambda and Spark Streaming to Process EC...
 
DevOps with Amazon Web Services (November 2016)
DevOps with Amazon Web Services (November 2016)DevOps with Amazon Web Services (November 2016)
DevOps with Amazon Web Services (November 2016)
 
AWS Code{Commit,Deploy,Pipeline} (June 2016)
 AWS Code{Commit,Deploy,Pipeline} (June 2016) AWS Code{Commit,Deploy,Pipeline} (June 2016)
AWS Code{Commit,Deploy,Pipeline} (June 2016)
 
Integrate AWS CodeDeploy With Git And Deploy A Revision
Integrate AWS CodeDeploy With Git And Deploy A RevisionIntegrate AWS CodeDeploy With Git And Deploy A Revision
Integrate AWS CodeDeploy With Git And Deploy A Revision
 
AWS July Webinar Series: Introducing AWS OpsWorks for Windows Server
AWS July Webinar Series: Introducing AWS OpsWorks for Windows ServerAWS July Webinar Series: Introducing AWS OpsWorks for Windows Server
AWS July Webinar Series: Introducing AWS OpsWorks for Windows Server
 
Agile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic BeanstalkAgile Deployment using Git and AWS Elastic Beanstalk
Agile Deployment using Git and AWS Elastic Beanstalk
 
Running Docker clusters on AWS (June 2016)
Running Docker clusters on AWS (June 2016)Running Docker clusters on AWS (June 2016)
Running Docker clusters on AWS (June 2016)
 
DevOps for the Enterprise: Automating Deployments
DevOps for the Enterprise: Automating DeploymentsDevOps for the Enterprise: Automating Deployments
DevOps for the Enterprise: Automating Deployments
 
AWS Webcast - Getting Started with AWS OpsWorks
AWS Webcast - Getting Started with AWS OpsWorksAWS Webcast - Getting Started with AWS OpsWorks
AWS Webcast - Getting Started with AWS OpsWorks
 
Aws meetup building_lambda
Aws meetup building_lambdaAws meetup building_lambda
Aws meetup building_lambda
 
Containers on AWS
Containers on AWSContainers on AWS
Containers on AWS
 
Amazon ECS (March 2016)
Amazon ECS (March 2016)Amazon ECS (March 2016)
Amazon ECS (March 2016)
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
CI&CD on AWS - Meetup Roma Oct 2016
CI&CD on AWS - Meetup Roma Oct 2016CI&CD on AWS - Meetup Roma Oct 2016
CI&CD on AWS - Meetup Roma Oct 2016
 
Releasing Software Quickly and Reliably With AWS CodePipeline by Mark Mansour...
Releasing Software Quickly and Reliably With AWS CodePipeline by Mark Mansour...Releasing Software Quickly and Reliably With AWS CodePipeline by Mark Mansour...
Releasing Software Quickly and Reliably With AWS CodePipeline by Mark Mansour...
 
Code Deploy
Code Deploy Code Deploy
Code Deploy
 
AWS Webcast - AWS OpsWorks Continuous Integration Demo
AWS Webcast - AWS OpsWorks Continuous Integration Demo  AWS Webcast - AWS OpsWorks Continuous Integration Demo
AWS Webcast - AWS OpsWorks Continuous Integration Demo
 
如何無痛上雲端? 以Elastic Beanstalk Java Container為例
如何無痛上雲端? 以Elastic Beanstalk Java Container為例如何無痛上雲端? 以Elastic Beanstalk Java Container為例
如何無痛上雲端? 以Elastic Beanstalk Java Container為例
 
Aws cli
Aws cliAws cli
Aws cli
 
Eks and fargate
Eks and fargateEks and fargate
Eks and fargate
 

Destacado

OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICONOSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
jochen.hiller
 
Data Science Experience
Data Science ExperienceData Science Experience
Data Science Experience
Zied ABIDI
 

Destacado (20)

Building a data warehouse with Amazon Redshift … and a quick look at Amazon ...
Building a data warehouse  with Amazon Redshift … and a quick look at Amazon ...Building a data warehouse  with Amazon Redshift … and a quick look at Amazon ...
Building a data warehouse with Amazon Redshift … and a quick look at Amazon ...
 
Workshop AWS IoT @ IoT World Paris
Workshop AWS IoT @ IoT World ParisWorkshop AWS IoT @ IoT World Paris
Workshop AWS IoT @ IoT World Paris
 
AWS CodeCommit, CodeDeploy & CodePipeline
AWS CodeCommit, CodeDeploy & CodePipelineAWS CodeCommit, CodeDeploy & CodePipeline
AWS CodeCommit, CodeDeploy & CodePipeline
 
Amazon Redshift (February 2016)
Amazon Redshift (February 2016)Amazon Redshift (February 2016)
Amazon Redshift (February 2016)
 
IoT: it's all about Data!
IoT: it's all about Data!IoT: it's all about Data!
IoT: it's all about Data!
 
Deep Dive: Amazon Relational Database Service (March 2017)
Deep Dive: Amazon Relational Database Service (March 2017)Deep Dive: Amazon Relational Database Service (March 2017)
Deep Dive: Amazon Relational Database Service (March 2017)
 
Fascinating Tales of a Strange Tomorrow
Fascinating Tales of a Strange TomorrowFascinating Tales of a Strange Tomorrow
Fascinating Tales of a Strange Tomorrow
 
AWS Security Best Practices (March 2017)
AWS Security Best Practices (March 2017)AWS Security Best Practices (March 2017)
AWS Security Best Practices (March 2017)
 
Amazon AI (February 2017)
Amazon AI (February 2017)Amazon AI (February 2017)
Amazon AI (February 2017)
 
Advanced Task Scheduling with Amazon ECS
Advanced Task Scheduling with Amazon ECSAdvanced Task Scheduling with Amazon ECS
Advanced Task Scheduling with Amazon ECS
 
Deep Dive: Amazon Redshift (March 2017)
Deep Dive: Amazon Redshift (March 2017)Deep Dive: Amazon Redshift (March 2017)
Deep Dive: Amazon Redshift (March 2017)
 
Deep Dive: Amazon Virtual Private Cloud (March 2017)
Deep Dive: Amazon Virtual Private Cloud (March 2017)Deep Dive: Amazon Virtual Private Cloud (March 2017)
Deep Dive: Amazon Virtual Private Cloud (March 2017)
 
Amazon Athena (March 2017)
Amazon Athena (March 2017)Amazon Athena (March 2017)
Amazon Athena (March 2017)
 
Amazon AI (March 2017)
Amazon AI (March 2017)Amazon AI (March 2017)
Amazon AI (March 2017)
 
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICONOSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
 
Building Scalable IoT Apps (QCon S-F)
Building Scalable IoT Apps (QCon S-F)Building Scalable IoT Apps (QCon S-F)
Building Scalable IoT Apps (QCon S-F)
 
Quel algo ml_pour_mon_probleme
Quel algo ml_pour_mon_problemeQuel algo ml_pour_mon_probleme
Quel algo ml_pour_mon_probleme
 
Data Science Experience
Data Science ExperienceData Science Experience
Data Science Experience
 
Event Driven Streaming Analytics - Demostration on Architecture of IoT
Event Driven Streaming Analytics - Demostration on Architecture of IoTEvent Driven Streaming Analytics - Demostration on Architecture of IoT
Event Driven Streaming Analytics - Demostration on Architecture of IoT
 
A short introduction to Spark and its benefits
A short introduction to Spark and its benefitsA short introduction to Spark and its benefits
A short introduction to Spark and its benefits
 

Similar a Hands-on with AWS IoT

Similar a Hands-on with AWS IoT (20)

AWS October Webinar Series - Getting Started with AWS IoT
AWS October Webinar Series - Getting Started with AWS IoTAWS October Webinar Series - Getting Started with AWS IoT
AWS October Webinar Series - Getting Started with AWS IoT
 
Hands-on with AWS IoT (November 2016)
Hands-on with AWS IoT (November 2016)Hands-on with AWS IoT (November 2016)
Hands-on with AWS IoT (November 2016)
 
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 ...
 
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
 
AWS Innovate: Building an Internet Connected Camera with AWS IoT- Tim Cruse
AWS Innovate: Building an Internet Connected Camera with AWS IoT- Tim CruseAWS Innovate: Building an Internet Connected Camera with AWS IoT- Tim Cruse
AWS Innovate: Building an Internet Connected Camera with AWS IoT- Tim Cruse
 
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)
 
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
 
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
 
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
 
AWS+Intel: Smart Greenhouse Demo
AWS+Intel: Smart Greenhouse DemoAWS+Intel: Smart Greenhouse Demo
AWS+Intel: Smart Greenhouse Demo
 
(MBL303) Build Mobile Apps for IoT Devices and IoT Apps for Devices
(MBL303) Build Mobile Apps for IoT Devices and IoT Apps for Devices(MBL303) Build Mobile Apps for IoT Devices and IoT Apps for Devices
(MBL303) Build Mobile Apps for IoT Devices and IoT Apps for Devices
 
Deep Dive on AWS IoT
Deep Dive on AWS IoTDeep Dive on AWS IoT
Deep Dive on AWS IoT
 
AWS IoT Deep Dive
AWS IoT Deep DiveAWS IoT Deep Dive
AWS IoT Deep Dive
 
AWS IoT - Introduction - Pop-up Loft
AWS IoT - Introduction - Pop-up LoftAWS IoT - Introduction - Pop-up Loft
AWS IoT - Introduction - Pop-up Loft
 
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
Amazon AWS IoT 利用 AWS IoT 開發智慧家居解決方案
 
AWS IoT Webinar
AWS IoT WebinarAWS IoT Webinar
AWS IoT Webinar
 
Internet of Things on AWS
Internet of Things on AWSInternet of Things on AWS
Internet of Things on AWS
 
IoT Smart Home
IoT Smart HomeIoT Smart Home
IoT Smart Home
 
Reply Webinar Online - Mastering AWS - IoT Advanced
Reply Webinar Online - Mastering AWS - IoT AdvancedReply Webinar Online - Mastering AWS - IoT Advanced
Reply Webinar Online - Mastering AWS - IoT Advanced
 
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
 

Más de Julien SIMON

Más de Julien SIMON (20)

An introduction to computer vision with Hugging Face
An introduction to computer vision with Hugging FaceAn introduction to computer vision with Hugging Face
An introduction to computer vision with Hugging Face
 
Reinventing Deep Learning
 with Hugging Face Transformers
Reinventing Deep Learning
 with Hugging Face TransformersReinventing Deep Learning
 with Hugging Face Transformers
Reinventing Deep Learning
 with Hugging Face Transformers
 
Building NLP applications with Transformers
Building NLP applications with TransformersBuilding NLP applications with Transformers
Building NLP applications with Transformers
 
Building Machine Learning Models Automatically (June 2020)
Building Machine Learning Models Automatically (June 2020)Building Machine Learning Models Automatically (June 2020)
Building Machine Learning Models Automatically (June 2020)
 
Starting your AI/ML project right (May 2020)
Starting your AI/ML project right (May 2020)Starting your AI/ML project right (May 2020)
Starting your AI/ML project right (May 2020)
 
Scale Machine Learning from zero to millions of users (April 2020)
Scale Machine Learning from zero to millions of users (April 2020)Scale Machine Learning from zero to millions of users (April 2020)
Scale Machine Learning from zero to millions of users (April 2020)
 
An Introduction to Generative Adversarial Networks (April 2020)
An Introduction to Generative Adversarial Networks (April 2020)An Introduction to Generative Adversarial Networks (April 2020)
An Introduction to Generative Adversarial Networks (April 2020)
 
AIM410R1 Deep learning applications with TensorFlow, featuring Fannie Mae (De...
AIM410R1 Deep learning applications with TensorFlow, featuring Fannie Mae (De...AIM410R1 Deep learning applications with TensorFlow, featuring Fannie Mae (De...
AIM410R1 Deep learning applications with TensorFlow, featuring Fannie Mae (De...
 
AIM361 Optimizing machine learning models with Amazon SageMaker (December 2019)
AIM361 Optimizing machine learning models with Amazon SageMaker (December 2019)AIM361 Optimizing machine learning models with Amazon SageMaker (December 2019)
AIM361 Optimizing machine learning models with Amazon SageMaker (December 2019)
 
AIM410R Deep Learning Applications with TensorFlow, featuring Mobileye (Decem...
AIM410R Deep Learning Applications with TensorFlow, featuring Mobileye (Decem...AIM410R Deep Learning Applications with TensorFlow, featuring Mobileye (Decem...
AIM410R Deep Learning Applications with TensorFlow, featuring Mobileye (Decem...
 
A pragmatic introduction to natural language processing models (October 2019)
A pragmatic introduction to natural language processing models (October 2019)A pragmatic introduction to natural language processing models (October 2019)
A pragmatic introduction to natural language processing models (October 2019)
 
Building smart applications with AWS AI services (October 2019)
Building smart applications with AWS AI services (October 2019)Building smart applications with AWS AI services (October 2019)
Building smart applications with AWS AI services (October 2019)
 
Build, train and deploy ML models with SageMaker (October 2019)
Build, train and deploy ML models with SageMaker (October 2019)Build, train and deploy ML models with SageMaker (October 2019)
Build, train and deploy ML models with SageMaker (October 2019)
 
The Future of AI (September 2019)
The Future of AI (September 2019)The Future of AI (September 2019)
The Future of AI (September 2019)
 
Building Machine Learning Inference Pipelines at Scale (July 2019)
Building Machine Learning Inference Pipelines at Scale (July 2019)Building Machine Learning Inference Pipelines at Scale (July 2019)
Building Machine Learning Inference Pipelines at Scale (July 2019)
 
Train and Deploy Machine Learning Workloads with AWS Container Services (July...
Train and Deploy Machine Learning Workloads with AWS Container Services (July...Train and Deploy Machine Learning Workloads with AWS Container Services (July...
Train and Deploy Machine Learning Workloads with AWS Container Services (July...
 
Optimize your Machine Learning Workloads on AWS (July 2019)
Optimize your Machine Learning Workloads on AWS (July 2019)Optimize your Machine Learning Workloads on AWS (July 2019)
Optimize your Machine Learning Workloads on AWS (July 2019)
 
Deep Learning on Amazon Sagemaker (July 2019)
Deep Learning on Amazon Sagemaker (July 2019)Deep Learning on Amazon Sagemaker (July 2019)
Deep Learning on Amazon Sagemaker (July 2019)
 
Automate your Amazon SageMaker Workflows (July 2019)
Automate your Amazon SageMaker Workflows (July 2019)Automate your Amazon SageMaker Workflows (July 2019)
Automate your Amazon SageMaker Workflows (July 2019)
 
Build, train and deploy ML models with Amazon SageMaker (May 2019)
Build, train and deploy ML models with Amazon SageMaker (May 2019)Build, train and deploy ML models with Amazon SageMaker (May 2019)
Build, train and deploy ML models with Amazon SageMaker (May 2019)
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 

Hands-on with AWS IoT

  • 1. Hands-on with AWS IoT Julien Simon Principal Technical Evangelist Amazon Web Services julsimon@amazon.fr @julsimon
  • 2. Agenda •  Overview of AWS IoT •  Devices & SDKs, with a focus on the Arduino Yún •  The MQTT protocol •  Creating and securing “things” •  Routing AWS IoT messages to other AWS services •  Debugging AWS IoT applications •  And lots of AWS CLI, yeah!
  • 3. 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 - - - - - 3rd party DEVICE SHADOW Persistent thing state during intermittent connections APPLICATIONS AWS IoT API DEVICE REGISTRY Identity and Management of your things *** NEW (April 7) : AWS IoT is now available in eu-central-1 (Frankfurt)
  • 5. Official AWS IoT Starter Kits
  • 6. Software platforms supported by AWS IoT •  Arduino: Arduino Yún platform •  Node.js: ideal for Embedded Linux •  C: ideal for embedded OS
  • 8. Arduino Yún SDK Arduino IDE and librairies http://arduino.org/software AWS IoT SDK https://github.com/aws/aws-iot- device-sdk-arduino-yun
  • 10. Requirements •  Thing Registry •  Secure Identity for Things •  Secure Communications with Things •  Fine-grained Authorization for: –  Thing Management –  Publish / Subscribe Access –  AWS Service Access
  • 11. Creating a thing % aws iot create-thing --thing-name myThing % aws iot describe-thing --thing-name myThing % aws iot list-things
  • 12. Creating a certificate and keys % aws iot create-keys-and-certificate --set-as-active --certificate-pem-outfile cert.pem --public-key-outfile publicKey.pem --private-key-outfile privateKey.pem *** NEW (April 11) : You can now use your own certificates The AWS IoT root certificate, the thing certificate and the thing private key must be installed on your device, e.g. https://github.com/aws/aws-iot-device-sdk-arduino-yun
  • 13. Creating a policy % cat myPolicy.json { "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action":["iot:*"], "Resource": ["*"] }] } % aws iot create-policy --policy-name PubSubToAnyTopic --policy-document file://myPolicy.json
  • 14. Assigning an identity to a Policy and a Thing % aws iot attach-principal-policy --policy-name PubSubToAnyTopic --principal CERTIFICATE_ARN % aws iot attach-thing-principal --thing-name myThing --principal CERTIFICATE_ARN
  • 15. Arduino : connecting to AWS IoT aws_iot_mqtt_client myClient; if((rc = myClient.setup(AWS_IOT_CLIENT_ID)) == 0) { // Load user configuration if((rc = myClient.config(AWS_IOT_MQTT_HOST, AWS_IOT_MQTT_PORT, AWS_IOT_ROOT_CA_PATH, AWS_IOT_PRIVATE_KEY_PATH, AWS_IOT_CERTIFICATE_PATH)) == 0) { if((rc = myClient.connect()) == 0) { // We are connected doSomethingUseful(); } } }
  • 17. MQTT Protocol MQTTS vs HTTPS: 93x faster throughput 11.89x less battery to send 170.9x less battery to receive 50% less power to stay connected 8x less network overhead Source: http://stephendnicholas.com/archives/1217 •  OASIS standard protocol (v3.1.1) •  Lightweight, transport protocol that is useful for connected devices •  Publish-subscribe with topics •  MQTT is used on oil rigs, connected trucks, and many more critical applications •  Until now, customers had to build, maintain and scale a broker to use MQTT with cloud applications
  • 19. MQTT: collect data from a device mydevices/4 mydevices/4
  • 20. MQTT: aggregate data from many devices mydevices/# mydevices/1 mydevices/2 mydevices/3 …. Amazon DynamoDB Applications
  • 21. MQTT: update a device mydevices/4 mydevices/4
  • 22. MQTT: QoS 0 (at most once) 1 2 3 4 5 6 1,2,3,5,6 Publish QoS0
  • 23. MQTT: QoS 1 (at least once) 1 2 3 4 5 4 1,2,3,4,5,6 6 PUBLISH QoS1 PUBLISH QoS1 PUBACK
  • 25. Arduino : subscribing and publishing to a topic if ((rc=myClient.subscribe(”myTopic", 1, msg_callback)) != 0) { Serial.println("Subscribe failed!"); Serial.println(rc); } if((rc = myClient.publish(”myTopic", msg, strlen(msg), 1, false)) != 0) { Serial.println("Publish failed!"); Serial.println(rc); }
  • 26. Arduino : callback for incoming messages // Basic callback function that prints out the message void msg_callback(char* src, int len) { Serial.println("CALLBACK:"); for(int i = 0; i < len; i++) { Serial.print(src[i]); } Serial.println(""); }
  • 27. Rules
  • 28. Granting AWS IoT access to AWS services DynamoDB LambdaAmazon Kinesis
  • 29. Defining a trust policy for AWS IoT % cat iot-role-trust.json { "Version":"2012-10-17", "Statement":[ { "Sid":"", "Effect":"Allow", "Principal":{ "Service":"iot.amazonaws.com" }, "Action":"sts:AssumeRole" } ] }
  • 30. Applying the trust policy to AWS IoT % aws iam create-role --role-name my-iot-role --assume-role-policy-document file://iot-role-trust.json { "Role": { "AssumeRolePolicyDocument": {…}, "RoleId": "AROAJY7VZX5GEZ3Q7ILU4", "CreateDate": "2016-03-19T12:07:03.904Z", "RoleName": "my-iot-role", "Path": "/", "Arn": "arn:aws:iam::613904931467:role/my-iot-role" } }
  • 31. 1. AWS Services (Direct Integration) Rules Engine Actions AWS IoT Rules 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 connect AWS IoT to External Endpoints and AWS Services. 2. Rest of AWS (via Amazon Kinesis, AWS Lambda, Amazon S3, and more) *** NEW (March 16) : direct integration with Amazon Elasticsearch & CloudWatch *** NEW (April 11) : direct integration with Amazon Machine Learning
  • 32. AWS IoT Rules Engine Rule Name Description SQL Statement Array of Actions Simple & Familiar Syntax -  SQL Statement to define topic filter -  Optional WHERE clause -  Advanced JSON support Many functions available -  String manipulation (regex support) -  Mathematical operations -  Crypto support -  UUID, Timestamp, rand, etc.
  • 33. Creating a rule to write to DynamoDB % cat topic1-dynamodb-rule.json { "sql": "SELECT * FROM 'topic1'", "ruleDisabled": false, "actions": [{ "dynamoDB": { "tableName": "iot-topic1-table", "roleArn": "arn:aws:iam::613904931467:role/my-iot-role", "hashKeyField": "deviceId", "hashKeyValue": "${deviceId}", "rangeKeyField": "timestamp", "rangeKeyValue": "${timestamp()}" } }] } % aws iot create-topic-rule --rule-name topic1-dynamodb-rule --topic-rule-payload file://topic1-dynamodb-rule.json
  • 35. How can you debug AWS IoT applications? •  Testing with MQTT.fx (or a similar tool) is not enough •  CloudWatch Logs: the only way to see what is happening inside AWS IoT –  Permission issue –  Rule issue –  Incorrect JSON message –  Etc. •  These logs are not enabled by default: –  Define a policy allowing AWS IoT to access CloudWatch logs –  Attach the policy to the AWS IoT role (same one as for external services)
  • 36. Defining a policy for CloudWatch Logs % cat iot-policy-logs.json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:PutMetricFilter", "logs:PutRetentionPolicy" ], "Resource": [ "*" ] } ] }
  • 37. Enabling CloudWatch Logs for AWS IoT % aws iam create-policy --policy-name my-iot-policy-logs --policy-document file://iot-policy-logs.json { "Policy": { "PolicyName": "my-iot-policy-logs", "CreateDate": "2016-03-19T12:24:16.072Z", "AttachmentCount": 0, "IsAttachable": true, "PolicyId": "ANPAIK73XIV3QG5FF5TX6", "DefaultVersionId": "v1", "Path": "/", "Arn": "arn:aws:iam::613904931467:policy/my-iot-policy-logs", "UpdateDate": "2016-03-19T12:24:16.072Z" } } % aws iam attach-role-policy --role-name my-iot-role --policy-arn "arn:aws:iam::613904931467:policy/my-iot-policy-logs" % aws iot set-logging-options --logging-options-payload roleArn="arn:aws:iam::613904931467:role/my-iot-role",logLevel="INFO"
  • 38. Demo : logging events in CloudWatch Logs
  • 39. Thank You ! Julien Simon julsimon@amazon.fr @julsimon