@crichardson 
AWS Lambda 
A quick introduction 
Chris Richardson 
Author of POJOs in Action 
Founder of the original CloudFoundry.com 
@crichardson 
chris@chrisrichardson.net 
http://plainoldobjects.com 
http://microservices.io
“The Magic Happens at the 
@crichardson 
Intersection of 
Functions, Events and Data”
@crichardson 
AWS Lambda is a PaaS* 
for 
event-driven microservices 
* in a restricted kind of way
NodeJS functions that consume 
events 
@crichardson 
S3 
Kinesis 
DynamoDB 
console.log('Loading event'); 
exports.handler = function(event, context) { 
console.log('value1 = ' + event.key1); 
console.log('value2 = ' + event.key2); 
console.log('value3 = ' + event.key3); 
context.done(null, 'Hello World'); 
}; 
Events 
Pricing (once you have exceeded the free tier) 
$0.0000002 per request 
$0.00001667 for every GB-second 
Invoke API
IAM role for lambda 
@crichardson 
NodeJS module 
Specify event handler 
execution 
Resource limits
@crichardson
NodeJS-powered home security 
@crichardson
NodeJS-powered home security 
FTP server Upload image 
IpCamViewer 
Web App 
@crichardson 
Log file Upload dir. 
Upload2S3 UploadQueue 
Processor 
S3 SQS Queue DynamoDB
IpCamViewer 
Web App 
@crichardson 
NodeJS + Lambda 
FTP server 
Log file Upload dir. 
Upload2S3 
S3 DynamoDB
Triggering 
events 
@crichardson 
S3 notifications 
Lambda to 
invoke 
Invoking IAM 
role
Promise-based event handling 
code 
Asynchronously 
process event 
@crichardson 
Invoke success/error handler when all 
events have been processed
s3ObjectProcessor.process() 
ultimately invokes AWS SDK 
@crichardson
@crichardson 
Uploading the lambda
@crichardson 
IAM role policies 
lambda_invoke_role lambda_exec_role 
Permission to invoke lambda 
Permission to access 
DynamoDB tables
@crichardson 
12 
aws s3 cp IMG_2824.jpg  
"s3://imagecamimage-std/partitions/20130217/ipcam/ipcam99/000DC5D76EFE(ipcam99)_1_20130217052637_1219.jpg" 
DynamoDB table lambda-imagesbyipcamandtimestamp(ipcam, timestamp) 
lambda-ipcambydayandtimebucket(ipcamandday)
@crichardson 
Cloud Watch logs
@crichardson 
Final thoughts 
Useful for writing “simple” AWS-oriented services 
What would be nice: 
Ability to specific environment variables for externalized 
configuration, e.g. names of AWS resources
@crichardson 
@crichardson chris@chrisrichardson.net 
http://plainoldobjects.com http://microservices.io

AWS Lambda - A quick introduction #advancedaws

  • 1.
    @crichardson AWS Lambda A quick introduction Chris Richardson Author of POJOs in Action Founder of the original CloudFoundry.com @crichardson chris@chrisrichardson.net http://plainoldobjects.com http://microservices.io
  • 2.
    “The Magic Happensat the @crichardson Intersection of Functions, Events and Data”
  • 3.
    @crichardson AWS Lambdais a PaaS* for event-driven microservices * in a restricted kind of way
  • 4.
    NodeJS functions thatconsume events @crichardson S3 Kinesis DynamoDB console.log('Loading event'); exports.handler = function(event, context) { console.log('value1 = ' + event.key1); console.log('value2 = ' + event.key2); console.log('value3 = ' + event.key3); context.done(null, 'Hello World'); }; Events Pricing (once you have exceeded the free tier) $0.0000002 per request $0.00001667 for every GB-second Invoke API
  • 5.
    IAM role forlambda @crichardson NodeJS module Specify event handler execution Resource limits
  • 6.
  • 7.
  • 8.
    NodeJS-powered home security FTP server Upload image IpCamViewer Web App @crichardson Log file Upload dir. Upload2S3 UploadQueue Processor S3 SQS Queue DynamoDB
  • 9.
    IpCamViewer Web App @crichardson NodeJS + Lambda FTP server Log file Upload dir. Upload2S3 S3 DynamoDB
  • 10.
    Triggering events @crichardson S3 notifications Lambda to invoke Invoking IAM role
  • 11.
    Promise-based event handling code Asynchronously process event @crichardson Invoke success/error handler when all events have been processed
  • 12.
  • 13.
  • 14.
    @crichardson IAM rolepolicies lambda_invoke_role lambda_exec_role Permission to invoke lambda Permission to access DynamoDB tables
  • 15.
    @crichardson 12 awss3 cp IMG_2824.jpg "s3://imagecamimage-std/partitions/20130217/ipcam/ipcam99/000DC5D76EFE(ipcam99)_1_20130217052637_1219.jpg" DynamoDB table lambda-imagesbyipcamandtimestamp(ipcam, timestamp) lambda-ipcambydayandtimebucket(ipcamandday)
  • 16.
  • 17.
    @crichardson Final thoughts Useful for writing “simple” AWS-oriented services What would be nice: Ability to specific environment variables for externalized configuration, e.g. names of AWS resources
  • 18.
    @crichardson @crichardson chris@chrisrichardson.net http://plainoldobjects.com http://microservices.io