AWS Lambda - A quick introduction #advancedaws
-
Upload
chris-richardson -
Category
Software
-
view
3.381 -
download
0
Transcript of AWS Lambda - A quick introduction #advancedaws
@crichardson
AWS LambdaA quick introduction
Chris Richardson
Author of POJOs in ActionFounder of the original CloudFoundry.com
@[email protected]://plainoldobjects.comhttp://microservices.io
@crichardson
“The Magic Happens at the Intersection of
Functions, Events and Data”
@crichardson
AWS Lambda is a PaaS*for
event-driven microservices
* in a restricted kind of way
@crichardson
NodeJS functions that consume events
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
@crichardson
NodeJS module
Specify event handler
Resource limits
IAM role for lambda execution
@crichardson
@crichardson
NodeJS-powered home security
@crichardson
NodeJS-powered home security
Upload2S3 UploadQueueProcessor
SQS Queue DynamoDBS3
Log file Upload dir.
IpCamViewerWeb App
FTP server Upload image
@crichardson
NodeJS + Lambda
Upload2S3
DynamoDBS3
Log file Upload dir.
IpCamViewerWeb App
FTP server
@crichardson
S3 notifications
Lambda to invoke
Invoking IAM role
Triggering events
@crichardson
Promise-based event handling code
Asynchronouslyprocess event
Invoke success/error handler when all events have been processed
@crichardson
s3ObjectProcessor.process() ultimately invokes AWS SDK
@crichardson
Uploading the lambda
@crichardson
IAM role policieslambda_exec_rolelambda_invoke_role
Permission to invoke lambda
Permission to access DynamoDB tables
@crichardson
aws s3 cp IMG_2824.jpg "s3://imagecamimage-std/partitions/20130217/ipcam/
ipcam99/000DC5D76EFE(ipcam99)_1_20130217052637_1219.jpg" 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