Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mobile apps and iot aws lambda

1,563 views

Published on

AWS Lambda is a new compute service that runs your code in response to events and automatically manages the compute resources for you. AWS Lambda enables powerful application architectures that simplify and accelerate development of connected applications. Together with Amazon Cognito, AWS SNS Push Notifications and AWS DynamoDB, AWS Lambda is a powerful tool in your arsenal for developing IoT/mobile apps, and beyond. This session will show you how to get started quickly by covering key architectural design concepts and demonstrating the use of the AWS SDKs to simplify creating powerful applications for the always-on world that connects beyond the desktop.

Speaker: Adam Larter, Solutions Architect, Amazon Web Services

Published in: Technology
  • Be the first to comment

Mobile apps and iot aws lambda

  1. 1. Mobile Applications and 
 The Internet of Things
 AWS Lambda & AWS Cognito
 Adam Larter, Solutions Architect Amazon Web Services
  2. 2. Business 101 Technical 201 Technical 301 Technical 401 Technical Session Grading
  3. 3. Agenda • Challenges when building Mobile/IoT applications • Discuss how AWS services help meet the challenges • Dive deep on AWS Cognito and AWS Lambda • IoT and Mobile demonstrations
  4. 4. IoT & Mobile demo
 “Beaconisis”
  5. 5. Beaconisis V1.0 • Uses Bluetooth LE (Low Energy) Beacons
 Received signal strength is converted to approx. distance in meters
 • Multiple Raspberry PIs create a ‘geo fence’
 Each RPI sends telemetry data to a Kinesis stream in real-time • Lambda function bound to Kinesis stream
 Processes records in real-time and makes data available to mobile app to trilaterate the position of the ‘target’ relative to the detectors

  6. 6. Beaconisis V1.0 – Detetctor flow Kinesis stream Lambda Function DynamoDB
  7. 7. Beaconisis V1.0 – Detetctor flow Detector 3 Detector 2Detector 1 Kinesis stream Lambda Function DynamoDB
  8. 8. Beaconisis V1.0 – Detetctor flow Detector 3 Detector 2Detector 1 Kinesis stream Lambda Function DynamoDB
  9. 9. Beaconisis V1.0 – Detetctor flow Detector 3 Detector 2Detector 1 Kinesis stream Lambda Function DynamoDB Lambda function filters the detection data, applies a Kalman filter to smooth the readings & updates DynamoDB
  10. 10. Beaconisis V1.0 – Detetctor flow Detector 3 Detector 2Detector 1 Kinesis stream Lambda Function DynamoDB Lambda function filters the detection data, applies a Kalman filter to smooth the readings & updates DynamoDB
  11. 11. Beaconisis V1.0 – ‘Tile’ beacon http://www.tomsguide.com/us/tile-android-app,news-20027.html
  12. 12. Beaconisis V1.0 – Sample payload
  13. 13. Beaconisis V1.0 – Sample payload Signal Strength measured at distance of 1 meter
  14. 14. Beaconisis V1.0 – Sample payload Signal Strength measured at distance of 1 meter Received Signal Strength Indicator = current measurement
  15. 15. Beaconisis V1.0 – Web page
  16. 16. Beaconisis V1.0 – Mobile App flow DynamoDB Cognito Identity
  17. 17. Beaconisis V1.0 – Mobile App flow DynamoDB Cognito Identity
  18. 18. Beaconisis V1.0 – Mobile App flow DynamoDB Using trilateration to determine the approximate location of the target within the boundary created by the detectors Cognito Identity
  19. 19. IoT & Mobile demo
 “Beaconisis”
  20. 20. IoT & Mobile demo
 “RFID Reader with Face Detection”
  21. 21. www.adafruit.com RFID reader – Hardware
  22. 22. RFID reader – Flow Initialise Cognito
  23. 23. RFID reader – Flow Initialise Cognito Blink LED to indicate Ready
  24. 24. RFID reader – Flow Initialise Cognito Blink LED to indicate Ready RFID detected Capture Image to local storage Steady LED to indicate image captured Ok
  25. 25. RFID reader – Flow Initialise Cognito Blink LED to indicate Ready RFID detected Capture Image to local storage RFID goes out of range Steady LED to indicate image captured Ok
  26. 26. RFID reader – Flow Initialise Cognito Blink LED to indicate Ready RFID detected Capture Image to local storage RFID goes out of range Steady LED to indicate image captured Ok Upload image to S3 with headers eg: RFID
  27. 27. RFID reader – Flow Initialise Cognito Blink LED to indicate Ready RFID detected Capture Image to local storage RFID goes out of range Steady LED to indicate image captured Ok Upload image to S3 with headers eg: RFID Blink LED to indicate done
  28. 28. RFID reader – Upload Response Architecture Mobile App S3 Upload Bucket Cognito Identity Lambda Function SNS Topic TOPIC SNS
  29. 29. RFID reader – Upload Response Architecture Mobile App S3 Upload Bucket Cognito Identity Lambda Function Image uploaded to S3 SNS Topic TOPIC SNS
  30. 30. RFID reader – Upload Response Architecture Mobile App S3 Upload Bucket Cognito Identity Lambda Function Image uploaded to S3 SNS Topic TOPIC SNS
  31. 31. RFID reader – Upload Response Architecture Mobile App S3 Upload Bucket Cognito Identity Lambda Function Image uploaded to S3 Push notification from GCM SNS Topic TOPIC SNS Guest access
  32. 32. Mobile App SQS Queue RFID reader – Command architecture S3 Upload Bucket SNS Topic TOPIC
  33. 33. Mobile App SQS Queue RFID reader – Command architecture S3 Upload Bucket SNS Topic TOPIC
  34. 34. Mobile App SQS Queue RFID reader – Command architecture S3 Upload Bucket SNS Topic TOPIC
  35. 35. Mobile App SQS Queue RFID reader – Command architecture Capture Image to local filesystem S3 Upload Bucket SNS Topic TOPIC
  36. 36. Mobile App SQS Queue RFID reader – Command architecture Capture Image to local filesystem S3 Upload Bucket SNS Topic TOPIC
  37. 37. Mobile App SQS Queue RFID reader – Command architecture Capture Image to local filesystem S3 Upload Bucket SNS Topic TOPIC
  38. 38. Mobile App SQS Queue RFID reader – Command architecture Capture Image to local filesystem S3 Upload Bucket SNS Topic TOPIC Push notification from GCM
  39. 39. IoT & Mobile demo
 “RFID Reader with Face Detection”
  40. 40. IoT & Mobile challenges • Devices constrained in at 
 least one computing dimension • Regularly deployed at counts 
 in the thousands, millions or more
 • May have minimal human interface or
 human operator interaction
 • Non-zero amount of compute – not just a sensor
  41. 41. • Authorisation
 Determine if a device should be allowed to do something • Telemetry
 Remotely determining what a device senses
 • Commands
 Issuing commands to the remote device
 IoT & Mobile challenges
  42. 42. Mobile &
 IoT IoT & Mobile challenges
  43. 43. Mobile &
 IoT Gap IoT & Mobile challenges
  44. 44. Mobile &
 IoT Global Ubiquity $0 Inbound Data Elasticity Purpose Built Services Global Object Store Audit 
 &
 Auth Amazon S3 Amazon Cognito Amazon DynamoDB Amazon Kinesis Amazon Lambda Amazon SNS How AWS meets Mobile & IoT challenges
  45. 45. How AWS meets Mobile & IoT challenges • Identity & data synchronisation
 Determine if a device or user is allowed to do something
 Share state between multiple instances of the app • Event-driven architectures
 Running code in response to events in the system Amazon Cognito Amazon Lambda
  46. 46. How AWS meets Mobile & IoT challenges • Identity & Access Management
 Secure, fine-grained control of cloud resources • Telemetry
 Remotely determining what a device senses
 High-velocity data streams
 • Commands
 Issuing commands to the remote device
 Amazon Kinesis Amazon SQS Amazon IAM
  47. 47. How AWS meets Mobile & IoT challenges • Shared data store
 High throughput NoSQL store • Push notification & synchronisation
 Notifying users of change in the system
 • Media & object store
 Highly durable object storage Amazon SNS Mobile Push Amazon S3 Amazon DynamoDB
  48. 48. AWS SDKs
  49. 49. Amazon Cognito
 Identity management, secure access and shared state
  50. 50. Amazon Cognito – two sides Cognito 
 Identity Broker Cognito
 Sync Store
  51. 51. Amazon Cognito – two sides Cognito 
 Identity Broker Cognito
 Sync Store Authorisation & Synchronisation
  52. 52. Amazon Cognito – authorisation • Simplifies security – Integrated with IAM Roles
 Fully integrated with IAM for secure & powerful 
 fine-grained access control 
 • Supports multiple Login Providers
 Easily integrate with major login providers (FB, Google+, 
 Login with Amazon, Twitter) and supports OIDC for authentication
 or create your own identity provider 
 • Supports un-authenticated ‘guests’
 Your users can be authorised anonymously if you choose

  53. 53. Amazon Cognito – data synchronisation • Cross-device and Cross-platform Push Sync
 Synchronize user’s data across devices and platforms – including actively pushing changes to all devices when one updates the shared data • Cognito Streams feature
 Automatically stream changes in user data to 
 Amazon Kinesis for processing
 • Sync Trigger – Cognito Event
 Execute a Lambda function to intercept changes in Cognito dataset
 • Programmatic access to sync store
 Run back-end processes that modify in-app data
 Just
 released
  54. 54. DynamoDB End Users Developer App w/SDK Cognito Identity Broker S3 Amazon Lambda Cognito Sync Store AWS Management Console Amazon Cognito Security Architecture
  55. 55. DynamoDB End Users Developer App w/SDK Cognito Identity Broker Login OAUTH/OpenID Access Token S3 Amazon Lambda Cognito Sync Store AWS Management Console Amazon Cognito Security Architecture
  56. 56. DynamoDB End Users Developer App w/SDK Cognito Identity Broker Login OAUTH/OpenID Access Token S3 Amazon Lambda Cognito Sync Store AWS Management Console Access Token Pool ID Role ARNs Amazon Cognito Security Architecture
  57. 57. DynamoDB End Users Developer App w/SDK Cognito Identity Broker Login OAUTH/OpenID Access Token Cognito ID, Temp Credentials S3 Amazon Lambda Cognito Sync Store AWS Management Console Access Token Pool ID Role ARNs Amazon Cognito Security Architecture
  58. 58. User ID (Temp Credentials) DynamoDB End Users Developer App w/SDK Access to AWS Services Cognito Identity Broker Login OAUTH/OpenID Access Token Cognito ID, Temp Credentials S3 Amazon Lambda Cognito Sync Store AWS Management Console Access Token Pool ID Role ARNs Amazon Cognito Security Architecture
  59. 59. User ID (Temp Credentials) DynamoDB End Users Developer App w/SDK Access to AWS Services Cognito Identity Broker Login OAUTH/OpenID Access Token Cognito ID, Temp Credentials S3 Amazon Lambda Cognito Sync Store AWS Management Console Access Token Pool ID Role ARNs Amazon Cognito Security Architecture
  60. 60. Amazon Cognito Push Synchronisation Cognito Identity
 Broker
  61. 61. Amazon Cognito Push Synchronisation Cognito Identity
 Broker
  62. 62. Amazon Cognito Push Synchronisation Cognito Sync Store Dataset
  63. 63. Amazon Cognito Push Synchronisation Cognito Sync Store Dataset
  64. 64. Amazon Cognito Push Synchronisation Cognito Sync Store Dataset
  65. 65. Amazon Cognito Push Synchronisation Mobile App
 initiates change Cognito Sync Store Dataset
  66. 66. Amazon Cognito Push Synchronisation Mobile App
 initiates change Cognito Sync Store Dataset Platform Application (SNS)
  67. 67. Amazon Cognito Push Synchronisation Mobile App
 initiates change Cognito Sync Store Mobile App
 receives change Dataset Platform Application (SNS)
  68. 68. Amazon Cognito Push Synchronisation Mobile App
 initiates change Cognito Sync Store Mobile App
 receives change Dataset
  69. 69. Amazon Cognito Sync Demo
  70. 70. Using Cognito in your Mobile App
  71. 71. Using Cognito in your Mobile App Just tell Cognito your Identity Pool’s ARN NEW!
  72. 72. Using Cognito in your Mobile App Simply instantiate the AmazonDynamoDBClient and specify your Cognito provider as the credential provider in the constructor
  73. 73. Using Cognito in your Web page (Javascript)
  74. 74. Using Cognito in your Web page (Javascript)
  75. 75. Using Cognito in your IoT device (Python)
  76. 76. Using Cognito in your IoT device (Python)
  77. 77. Amazon Lambda
 Zero-administration compute
  78. 78. Amazon Lambda
 is connective tissue for AWS services
  79. 79. Amazon S3 Amazon DynamoDB Amazon SNS Amazon Kinesis Amazon Cognito Amazon Lambda
 is connective tissue for AWS services
  80. 80. Amazon Lambda • Zero Administration
 Focus on business logic, not infrastructure. 
 Just upload your code & Lambda handles everything else • Auto Scaling
 Lambda scales the infrastructure as needed to 
 match the event rate and pay as you go
 • Bring your own Code
 Node.JS available now with other languages to follow.
 Create threads and processes, run batch scripts or other exe’s 

  81. 81. Amazon Lambda – Hot off the press! • Synchronous events
 Respond to application calls with low-latency real-time functions
 • Trigger Lambda Functions Using Amazon SNS 
 Respond dynamically and automatically to SNS notifications
 • Multiple Lambda Functions for Kinesis & DynamoDB Streams
 Attach one or more Lambda functions to handle stream events 
 Just
 released
  82. 82. Demo: Setting up a Lambda function
  83. 83. Amazon Cognito & Amazon Lambda together
 Cognito Events – “Sync Trigger” Mobile App
 initiates change Cognito Sync Store Lambda Function
  84. 84. Amazon Cognito & Amazon Lambda together
 Cognito Events – “Sync Trigger” Mobile App
 initiates change Cognito Sync Store Lambda Function
  85. 85. Sync Trigger Amazon Cognito & Amazon Lambda together
 Cognito Events – “Sync Trigger” Mobile App
 initiates change Cognito Sync Store Kinesis Stream Lambda Function Lambda Function Lambda Function
  86. 86. Sync Trigger Amazon Cognito & Amazon Lambda together
 Cognito Events – “Sync Trigger” Mobile App
 initiates change Cognito Sync Store Kinesis Stream Lambda Function Lambda Function Lambda Function Lambda Function Lambda Function Synchronous
call Synchronous
 call
  87. 87. Demo: Amazon Cognito
 & Amazon Lambda
  88. 88. Amazon Lambda • Respond to events raised by AWS services
 Eg: Face detection on images
 • Implement stream processing
 Attach compute to records in a Kinesis stream
 • Synchronous function calls
 Standard web request/response model • Perfect for server-less Mobile/IoT apps (& more)
 …as you’ve seen in today’s demonstrations!
  89. 89. Amazon Cognito • Secure, Fine-grained access control
 Fully integrated with IAM Roles
 • Supports multiple Login Providers
 FB, G+, AMZ, ‘Roll your own’ or any OIDC source
 • Cross-device and Cross-platform
 Users access shared data from any device
 • Sync Sync Sync! 
 Push Sync, manual Sync, programmatic Sync and Sync Triggers

  90. 90. Amazon Cognito
 & Amazon Lambda
 Better together!

×