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
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
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
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
24. RFID reader – Flow
Initialise Cognito
Blink LED to
indicate Ready
25. RFID reader – Flow
Initialise Cognito
Blink LED to
indicate Ready
RFID detected
Capture Image to
local storage
Steady LED to
indicate image
captured Ok
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
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
28. 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
29. RFID reader – Upload Response Architecture
Mobile
App
S3 Upload
Bucket
Cognito
Identity
Lambda
Function
SNS Topic
TOPIC
SNS
30. RFID reader – Upload Response Architecture
Mobile
App
S3 Upload
Bucket
Cognito
Identity
Lambda
Function
Image uploaded to S3
SNS Topic
TOPIC
SNS
31. RFID reader – Upload Response Architecture
Mobile
App
S3 Upload
Bucket
Cognito
Identity
Lambda
Function
Image uploaded to S3
SNS Topic
TOPIC
SNS
32. 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
36. Mobile App
SQS Queue
RFID reader – Command architecture
Capture Image to
local filesystem
S3 Upload
Bucket
SNS Topic
TOPIC
37. Mobile App
SQS Queue
RFID reader – Command architecture
Capture Image to
local filesystem
S3 Upload
Bucket
SNS Topic
TOPIC
38. Mobile App
SQS Queue
RFID reader – Command architecture
Capture Image to
local filesystem
S3 Upload
Bucket
SNS Topic
TOPIC
39. Mobile App
SQS Queue
RFID reader – Command architecture
Capture Image to
local filesystem
S3 Upload
Bucket
SNS Topic
TOPIC
Push
notification
from GCM
40. IoT & Mobile demo
“RFID Reader with Face Detection”
41. 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
42. • 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
45. 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
46. 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
47. 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
48. 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
51. Amazon Cognito – two sides
Cognito
Identity Broker
Cognito
Sync Store
52. Amazon Cognito – two sides
Cognito
Identity Broker
Cognito
Sync Store
Authorisation & Synchronisation
53. 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
54. 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
72. Using Cognito in your Mobile App
Just tell Cognito your
Identity Pool’s ARN
NEW!
73. Using Cognito in your Mobile App
Simply instantiate the AmazonDynamoDBClient
and specify your Cognito provider as the
credential provider in the constructor
80. Amazon S3 Amazon DynamoDB Amazon SNS Amazon Kinesis Amazon Cognito
Amazon Lambda
is connective tissue for AWS services
81. 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
82. 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
84. Amazon Cognito & Amazon Lambda together
Cognito Events – “Sync Trigger”
Mobile App
initiates change
Cognito Sync
Store
Lambda
Function
85. Amazon Cognito & Amazon Lambda together
Cognito Events – “Sync Trigger”
Mobile App
initiates change
Cognito Sync
Store
Lambda
Function
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
87. 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
89. 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!
90. 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