SlideShare a Scribd company logo
1 of 39
Download to read offline
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

More Related Content

What's hot

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

What's hot (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
 

Viewers also liked

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
 

Viewers also liked (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 to Hands-on with AWS IoT

Similar to 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
 

More from Julien SIMON

More from 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)
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

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