SlideShare a Scribd company logo
A W S I O T &
L A M B D A
A TALE ABOUT A DOG AND A LASER POINTER
BY LISA KESTER
Twitter @injectgeek
Walkthrough at
https://www.hackster.io/happy-puppy-or-not/fido-s-automated-lazer-pointer-9be48a
FIRST THERE
WAS…
Boredom Sleeping Play Time
WHAT’S INVOLVED IN AUTOMATING
THE LAZER POINTER?
• AWS IoT service (device communication)
• AWS Lambda function (REST API access)
• Servo movement program on Arduino
• Raspberry PI program to listen for commands
• Connect hardware: servos, Raspberry pi, Arduino, breadboard, wires
• 3D print, design, and assemble the X/Y Bot
BRING DOG!
EXPLODED VIEW OF X/Y BOT
Designed, assembled, and 3D modeled by ERIC
SARELLANA
Finished automated laser pointer
device
WHAT ARE WE GOING TO TALK ABOUT?
(WHILE THE LASER POINTER RANDOMLY GOES OFF)
• IoT service overview
• How to setup the IoT service. (DEMO)
• Raspberry pi script (AWS IoT sdk)
• Lambda service overview
• How to setup the lambda service (DEMO)
• How to add a REST API call for the Lambda function (DEMO)
• How to schedule the Lambda function (DEMO)
• Lambda function testing and aliases (DEMO)
IOT SERVICE OVERVIEW
HOW IT WORKS
• Thing, Certificate, and Policy.
• A message is sent to the device (JSON)
• Shadow saves the message as internal
state and sends it to the device (JSON)
• Shadow retains state when device is off
• Device reacts to JSON via pub/sub model
• Optional Rules Engine (sends JSON to
Lambda,
Dynamo DB, some others…).
Device
“Thing”
Sends JSON Message with
AWS
ServicesShado
w
Rules EngineWHAT’S IT FOR?
The IoT service gives you a way to
control your device, route data to
AWS services. It includes security
and control over your users.
DEMO IOT SETUP
• Create thing
• Create certificate
• Create policy
• Attach certificate to policy and thing via “Actions” button
• NOTE: To delete an item, click on it and select “Delete” from the “Actions”
button. You may have to disable the certificate or detach the thing and policy
to delete individual items.
OR… After you create a thing, click on it, there is an option to “Connect to a
Device” in the Thing Details. Follow the prompts.
CREATE THING
(IF DEMO DIDN’T WORK)
CREATE CERTIFICATE & POLICY
The certificate and policy allow your device to interact with the IoT
service and receive messages from the cloud. You’ll need
additional policy(s)/roles for any rules you create.
GET JSON
MAKE SURE YOU
• Download all the certificates – some aren’t
available again!
• Save the JSON in this screen. You’ll use it
when you write the JavaScript program on
your device.
• README on GitHub has root-CA.crt.
(rename the extension if it’s wrong).
• Example “echo” program is great to get you
started listening for messages from the IoT
Service.
RASPBERRY PI SCRIPT
(Using AWS IoT JavaScript SDK)
Setup
• Install NodeJS & AWS IoT JavaScript SDK on the Raspberry PI
What does this do?
• It allows us to listen for changes to the shadow JSON and DO something as a
result.
• Subscribes to the MQTT Topic (pub/sub)
• Authenticates via certificates
AWS LAMBDA SERVICE OVERVIEW
• Run single functions
• No environment setup.
• Fault-tolerant (auto-retries), auto-scaling, replication, redundancy, sync/async,
zero maintenance!
• JavaScript, Java, Python supported
• Full access to AWS JavaScript, Java, and Python SDKs built in.
• Processing power and RAM assigned together (1.5GB Max RAM)
• Lambda functions aren’t publicly accessible (Extra secure)
• AWS API Gateway integration (public/private API access)
• Schedule execution of lambda functions (Cloudwatch events)
• Cost = execution time & processing power
• Create a JavaScript NodeJS function in index.js file
• Package program and dependencies in ZIP file
• Event and context give you access to parameters/JSON passed to the lambda
function.
HOW TO CREATE A LAMBDA FUNCTION
(USING NODEJS)
Index.js
var aws = require('aws-sdk');
exports.handler = function(event,
context) {
// Do Everything here
}
FILE NAME for
config
HANDLER NAME for config
CREATE LAMBDA FUNCTION
STEPS
• Go to the Lambda Service in AWS
• Create a new function
• Select your preferred language
• Select blueprint (for help to get
started)
• Or Skip to create function from
scratch
CONFIGURE LAMBDA FUNCTION
SETUP HIGHLIGHTS
Runtime – determines
language
Handler name MUST match the
function name in code.
Index is the name of the file
that contains the handler
function.
Role is for permissions.
Lambda has some good
defaults but you can create
one in IAM.
Memory determines RAM and
PROCESSING POWER.
Timeout is a failsafe so your
function is killed to minimize
ADD CODE
3 OPTIONS
• Write inline code
• Upload a zip file
• Upload to S3
• Uploading a zip file to S3
allows you to update the
lambda function by just
updating the file in S3.
• If you upload a zip file
inline, make sure you keep
a copy. I haven’t seen a
download option.
CREATE API GATEWAY ENDPOINT
HIGHLIGHTS
• API Name is the name of the API created
in API Gateway
• Resource name is the REST endpoint
name
• Security gives you options to allow
anyone to use the REST endpoint or to
require a Gateway API key
SCHEDULE THE LAZER POINTER EVENTS
CRON EXPRESSION Rules/Examples
here
STEPS
• The Event Sources tab has “Add Event Source”
• Select CloudWatch Events.
• Assign a schedule expression.
TESTING LAMBDA FUNCTIONS AND ALIASES
• DEMO
NOW…
CATCH THAT
LASER!
Q U E S T I O N S ?
A TALE ABOUT A DOG AND A LASER POINTER
BY LISA KESTER
Twitter @injectgeek
Walkthrough at
https://www.hackster.io/happy-puppy-or-not/fido-s-automated-lazer-pointer-9be48a

More Related Content

What's hot (11)

PDF
Serverless in production, an experience report (JeffConf)
Yan Cui
 
PPTX
Crunch Your Data in the Cloud with Elastic Map Reduce - Amazon EMR Hadoop
Adrian Cockcroft
 
PDF
Serverless - When to FaaS?
Benny Bauer
 
PPTX
JakartaJS: Serverless in production
Adhy Wiranata Prasetyo
 
PDF
Serverless
Young Yang
 
PDF
Build an Alexa Skill Step-by-Step
Rick Wargo
 
PDF
Ben Kehoe - Serverless Architecture for the Internet of Things
ServerlessConf
 
PDF
The Rise of Serverless Architectures
Benny Bauer
 
PDF
A 60-mn tour of AWS compute (March 2016)
Julien SIMON
 
PDF
Jets: The Ruby Serverless Framework Nashville Tennessee 2019 August
Tung Nguyen
 
PDF
Using the Event Gateway To Build Multi-Cloud Serverless Applications - JeffCo...
Philipp Müns
 
Serverless in production, an experience report (JeffConf)
Yan Cui
 
Crunch Your Data in the Cloud with Elastic Map Reduce - Amazon EMR Hadoop
Adrian Cockcroft
 
Serverless - When to FaaS?
Benny Bauer
 
JakartaJS: Serverless in production
Adhy Wiranata Prasetyo
 
Serverless
Young Yang
 
Build an Alexa Skill Step-by-Step
Rick Wargo
 
Ben Kehoe - Serverless Architecture for the Internet of Things
ServerlessConf
 
The Rise of Serverless Architectures
Benny Bauer
 
A 60-mn tour of AWS compute (March 2016)
Julien SIMON
 
Jets: The Ruby Serverless Framework Nashville Tennessee 2019 August
Tung Nguyen
 
Using the Event Gateway To Build Multi-Cloud Serverless Applications - JeffCo...
Philipp Müns
 

Similar to An Automated Laser Pointer for Your Dog : Aws IoT & Lambda (20)

PDF
Serverless in production, an experience report (Going Serverless)
Yan Cui
 
PDF
Building Serverless APIs (January 2017)
Julien SIMON
 
PDF
Serverless in production, an experience report (linuxing in london)
Yan Cui
 
PDF
Serverless in production, an experience report
Yan Cui
 
PDF
用Serverless技術快速開發line聊天機器人
Kevin Luo
 
PDF
Continuous Deployment @ AWS Re:Invent
John Schneider
 
PDF
Getting started with AWS IoT on Raspberry Pi
Ian Massingham
 
PDF
Serverless in production, an experience report (CoDe-Conf)
Yan Cui
 
PDF
10 Tips For Serverless Backends With NodeJS and AWS Lambda
Jim Lynch
 
PDF
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
Bishop Fox
 
PDF
Serverless in production, an experience report (FullStack 2018)
Yan Cui
 
PDF
IBM Think Session 8598 Domino and JavaScript Development MasterClass
Paul Withers
 
PDF
Aws-What You Need to Know_Simon Elisha
Helen Rogers
 
PDF
Serverless in Production, an experience report (AWS UG South Wales)
Yan Cui
 
PDF
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Paweł Pikuła
 
PDF
Serverless Rust: Your Low-Risk Entry Point to Rust in Production (and the ben...
Luciano Mammino
 
PDF
Introduction to the Serverless paradigm
Alex Casalboni
 
PDF
Getting Started with AWS Lambda & Serverless Cloud
Ian Massingham
 
PPTX
Intro to "Asgard"
Pritiman Panda
 
PDF
Serverless Architecture - A Gentle Overview
CodeOps Technologies LLP
 
Serverless in production, an experience report (Going Serverless)
Yan Cui
 
Building Serverless APIs (January 2017)
Julien SIMON
 
Serverless in production, an experience report (linuxing in london)
Yan Cui
 
Serverless in production, an experience report
Yan Cui
 
用Serverless技術快速開發line聊天機器人
Kevin Luo
 
Continuous Deployment @ AWS Re:Invent
John Schneider
 
Getting started with AWS IoT on Raspberry Pi
Ian Massingham
 
Serverless in production, an experience report (CoDe-Conf)
Yan Cui
 
10 Tips For Serverless Backends With NodeJS and AWS Lambda
Jim Lynch
 
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
Bishop Fox
 
Serverless in production, an experience report (FullStack 2018)
Yan Cui
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
Paul Withers
 
Aws-What You Need to Know_Simon Elisha
Helen Rogers
 
Serverless in Production, an experience report (AWS UG South Wales)
Yan Cui
 
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Paweł Pikuła
 
Serverless Rust: Your Low-Risk Entry Point to Rust in Production (and the ben...
Luciano Mammino
 
Introduction to the Serverless paradigm
Alex Casalboni
 
Getting Started with AWS Lambda & Serverless Cloud
Ian Massingham
 
Intro to "Asgard"
Pritiman Panda
 
Serverless Architecture - A Gentle Overview
CodeOps Technologies LLP
 
Ad

Recently uploaded (20)

PPTX
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
 
PDF
AI Software Development Process, Strategies and Challenges
Net-Craft.com
 
PPTX
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
PPTX
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 
PDF
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 
PPTX
For my supp to finally picking supp that work
necas19388
 
PPTX
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
PDF
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
PDF
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
PDF
Which Hiring Management Tools Offer the Best ROI?
HireME
 
DOCX
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
PPTX
arctitecture application system design os dsa
za241967
 
PDF
Automated Test Case Repair Using Language Models
Lionel Briand
 
PDF
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
PDF
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
PDF
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
PPTX
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
PDF
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
PDF
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
 
AI Software Development Process, Strategies and Challenges
Net-Craft.com
 
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 
For my supp to finally picking supp that work
necas19388
 
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
Which Hiring Management Tools Offer the Best ROI?
HireME
 
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
arctitecture application system design os dsa
za241967
 
Automated Test Case Repair Using Language Models
Lionel Briand
 
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
Ad

An Automated Laser Pointer for Your Dog : Aws IoT & Lambda

  • 1. A W S I O T & L A M B D A A TALE ABOUT A DOG AND A LASER POINTER BY LISA KESTER Twitter @injectgeek Walkthrough at https://www.hackster.io/happy-puppy-or-not/fido-s-automated-lazer-pointer-9be48a
  • 3. WHAT’S INVOLVED IN AUTOMATING THE LAZER POINTER? • AWS IoT service (device communication) • AWS Lambda function (REST API access) • Servo movement program on Arduino • Raspberry PI program to listen for commands • Connect hardware: servos, Raspberry pi, Arduino, breadboard, wires • 3D print, design, and assemble the X/Y Bot BRING DOG!
  • 4. EXPLODED VIEW OF X/Y BOT Designed, assembled, and 3D modeled by ERIC SARELLANA Finished automated laser pointer device
  • 5. WHAT ARE WE GOING TO TALK ABOUT? (WHILE THE LASER POINTER RANDOMLY GOES OFF) • IoT service overview • How to setup the IoT service. (DEMO) • Raspberry pi script (AWS IoT sdk) • Lambda service overview • How to setup the lambda service (DEMO) • How to add a REST API call for the Lambda function (DEMO) • How to schedule the Lambda function (DEMO) • Lambda function testing and aliases (DEMO)
  • 6. IOT SERVICE OVERVIEW HOW IT WORKS • Thing, Certificate, and Policy. • A message is sent to the device (JSON) • Shadow saves the message as internal state and sends it to the device (JSON) • Shadow retains state when device is off • Device reacts to JSON via pub/sub model • Optional Rules Engine (sends JSON to Lambda, Dynamo DB, some others…). Device “Thing” Sends JSON Message with AWS ServicesShado w Rules EngineWHAT’S IT FOR? The IoT service gives you a way to control your device, route data to AWS services. It includes security and control over your users.
  • 7. DEMO IOT SETUP • Create thing • Create certificate • Create policy • Attach certificate to policy and thing via “Actions” button • NOTE: To delete an item, click on it and select “Delete” from the “Actions” button. You may have to disable the certificate or detach the thing and policy to delete individual items. OR… After you create a thing, click on it, there is an option to “Connect to a Device” in the Thing Details. Follow the prompts.
  • 8. CREATE THING (IF DEMO DIDN’T WORK)
  • 9. CREATE CERTIFICATE & POLICY The certificate and policy allow your device to interact with the IoT service and receive messages from the cloud. You’ll need additional policy(s)/roles for any rules you create.
  • 10. GET JSON MAKE SURE YOU • Download all the certificates – some aren’t available again! • Save the JSON in this screen. You’ll use it when you write the JavaScript program on your device. • README on GitHub has root-CA.crt. (rename the extension if it’s wrong). • Example “echo” program is great to get you started listening for messages from the IoT Service.
  • 11. RASPBERRY PI SCRIPT (Using AWS IoT JavaScript SDK) Setup • Install NodeJS & AWS IoT JavaScript SDK on the Raspberry PI What does this do? • It allows us to listen for changes to the shadow JSON and DO something as a result. • Subscribes to the MQTT Topic (pub/sub) • Authenticates via certificates
  • 12. AWS LAMBDA SERVICE OVERVIEW • Run single functions • No environment setup. • Fault-tolerant (auto-retries), auto-scaling, replication, redundancy, sync/async, zero maintenance! • JavaScript, Java, Python supported • Full access to AWS JavaScript, Java, and Python SDKs built in. • Processing power and RAM assigned together (1.5GB Max RAM) • Lambda functions aren’t publicly accessible (Extra secure) • AWS API Gateway integration (public/private API access) • Schedule execution of lambda functions (Cloudwatch events) • Cost = execution time & processing power
  • 13. • Create a JavaScript NodeJS function in index.js file • Package program and dependencies in ZIP file • Event and context give you access to parameters/JSON passed to the lambda function. HOW TO CREATE A LAMBDA FUNCTION (USING NODEJS) Index.js var aws = require('aws-sdk'); exports.handler = function(event, context) { // Do Everything here } FILE NAME for config HANDLER NAME for config
  • 14. CREATE LAMBDA FUNCTION STEPS • Go to the Lambda Service in AWS • Create a new function • Select your preferred language • Select blueprint (for help to get started) • Or Skip to create function from scratch
  • 15. CONFIGURE LAMBDA FUNCTION SETUP HIGHLIGHTS Runtime – determines language Handler name MUST match the function name in code. Index is the name of the file that contains the handler function. Role is for permissions. Lambda has some good defaults but you can create one in IAM. Memory determines RAM and PROCESSING POWER. Timeout is a failsafe so your function is killed to minimize
  • 16. ADD CODE 3 OPTIONS • Write inline code • Upload a zip file • Upload to S3 • Uploading a zip file to S3 allows you to update the lambda function by just updating the file in S3. • If you upload a zip file inline, make sure you keep a copy. I haven’t seen a download option.
  • 17. CREATE API GATEWAY ENDPOINT HIGHLIGHTS • API Name is the name of the API created in API Gateway • Resource name is the REST endpoint name • Security gives you options to allow anyone to use the REST endpoint or to require a Gateway API key
  • 18. SCHEDULE THE LAZER POINTER EVENTS CRON EXPRESSION Rules/Examples here STEPS • The Event Sources tab has “Add Event Source” • Select CloudWatch Events. • Assign a schedule expression.
  • 19. TESTING LAMBDA FUNCTIONS AND ALIASES • DEMO
  • 21. Q U E S T I O N S ? A TALE ABOUT A DOG AND A LASER POINTER BY LISA KESTER Twitter @injectgeek Walkthrough at https://www.hackster.io/happy-puppy-or-not/fido-s-automated-lazer-pointer-9be48a