AWSome Day 2018
Serverless API with
Amazon Web Services
AWSome Day - Torino 2018
Gabriele Mittica
Co-founder Corley
Co-Ideator CloudConf
@gabrielemittica
gabriele.mittica@corley.it
corley.it
Scalability and cost optimization with Container Services
Scalable API
Serverless introduction
Serverless API with AWS
Benefits
Summary
Scalable API
➢ REST as architectural pattern
➢ Performance
➢ Decoupling
Key points in API development
Serverless
➢ different architecture
➢ different pricing
➢ different approach
➢ 99,999999999% durability
➢ HTTP based and easy SDK integration
➢ Tagging, versioning, logging, retention policy,
events, website hosting...
Simple Storage Service
var params = {Bucket: 'bucket', Key:
'key', Body: stream};
s3.upload(params, function(err, data) {
console.log(err, data);
});
Simple Storage Service (noedjs)
Remote Integration - S3
➢ run code without provisioning or managing
servers
➢ computation on demand
➢ several languages supported
Lambda
exports.handler = function (event, context) {
console.log(event);
context.succeed('hello ' + event.name);
};
Lambda
Remote Integration - Lambda
➢ create gateway for remote API
➢ connect to different origin: S3, remote API,
Lambda
➢ manage input and output transformation
API Gateway
➢ NoSQL DB that delivers reliable performance at
any scale
➢ designed for high performance
➢ pay-per-use
➢ events
DynamoDB
How to create
Serverless API
API Gateway + Lambda
API Gateway + Lambda
API Gateway + Lambda + DynamoDB
var AWS = require('aws-sdk');
AWS.config.update({region: 'REGION'});
ddb = new AWS.DynamoDB({apiVersion: '2012-10-08'});
var params = {
TableName: 'TABLE',
Item: {
'CUSTOMER_ID' : {N: '001'},
'CUSTOMER_NAME' : {S: 'Richard Roe'},
}
};
// Call DynamoDB to add the item to the table
ddb.putItem(params, function(err, data) {
if (err) { console.log("Error", err); }
else { console.log("Success", data); }
});
Lambda to DynamoDB
API Gateway + Lambda + DynamoDB + S3
➢ several events available on platform
➢ connect S3, Lambda, Dynamo, SNS, SQS and
other services together
➢ create responsive and modern architectures for
API
Introducing events
API Gateway + Lambda + DynamoDB + S3
API Gateway + Lambda + DynamoDB + S3 + Cognito
Simple Storage Service (browser)
Simple Storage Service (browser)
function addPhoto(albumName) {
var files = document.getElementById('photoupload').files;
if (!files.length) {
return alert('Please choose a file to upload first.');
}
var file = files[0];
var fileName = file.name;
var albumPhotosKey = encodeURIComponent(albumName) + '//';
var photoKey = albumPhotosKey + fileName;
s3.upload({
Key: photoKey,
Body: file,
ACL: 'public-read'
}, function(err, data) {
if (err) {
return alert('There was an error uploading your photo: ',
err.message);
}
alert('Successfully uploaded photo.');
viewAlbum(albumName);
});
}
API Gateway + Lambda + DynamoDB + S3 + Cognito
Access to reserved rows and/or columns in
DynamoDB
API Gateway + Lambda + DynamoDB + S3 + Cognito
When is useful?
➢ Really scalable
➢ Pay per use
➢ Understand new techs
➢ Deploy new
architectures
API Serverless
Atomic pricing
You can calculate the exact price
of each operation on cloud
How to move to serverless pattern
➢ choose right services
➢ define a roadmap
➢ code
Thanks for listening.
AWSome Day - Torino 2018 - gabriele.mittica@corley.it

AWSome day 2018 - API serverless with aws

  • 1.
    AWSome Day 2018 ServerlessAPI with Amazon Web Services AWSome Day - Torino 2018
  • 2.
    Gabriele Mittica Co-founder Corley Co-IdeatorCloudConf @gabrielemittica gabriele.mittica@corley.it corley.it
  • 3.
    Scalability and costoptimization with Container Services Scalable API Serverless introduction Serverless API with AWS Benefits Summary
  • 5.
  • 6.
    ➢ REST asarchitectural pattern ➢ Performance ➢ Decoupling Key points in API development
  • 7.
    Serverless ➢ different architecture ➢different pricing ➢ different approach
  • 8.
    ➢ 99,999999999% durability ➢HTTP based and easy SDK integration ➢ Tagging, versioning, logging, retention policy, events, website hosting... Simple Storage Service
  • 9.
    var params ={Bucket: 'bucket', Key: 'key', Body: stream}; s3.upload(params, function(err, data) { console.log(err, data); }); Simple Storage Service (noedjs)
  • 10.
  • 11.
    ➢ run codewithout provisioning or managing servers ➢ computation on demand ➢ several languages supported Lambda
  • 12.
    exports.handler = function(event, context) { console.log(event); context.succeed('hello ' + event.name); }; Lambda
  • 13.
  • 14.
    ➢ create gatewayfor remote API ➢ connect to different origin: S3, remote API, Lambda ➢ manage input and output transformation API Gateway
  • 15.
    ➢ NoSQL DBthat delivers reliable performance at any scale ➢ designed for high performance ➢ pay-per-use ➢ events DynamoDB
  • 17.
  • 18.
  • 19.
  • 20.
    API Gateway +Lambda + DynamoDB
  • 21.
    var AWS =require('aws-sdk'); AWS.config.update({region: 'REGION'}); ddb = new AWS.DynamoDB({apiVersion: '2012-10-08'}); var params = { TableName: 'TABLE', Item: { 'CUSTOMER_ID' : {N: '001'}, 'CUSTOMER_NAME' : {S: 'Richard Roe'}, } }; // Call DynamoDB to add the item to the table ddb.putItem(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data); } }); Lambda to DynamoDB
  • 22.
    API Gateway +Lambda + DynamoDB + S3
  • 23.
    ➢ several eventsavailable on platform ➢ connect S3, Lambda, Dynamo, SNS, SQS and other services together ➢ create responsive and modern architectures for API Introducing events
  • 24.
    API Gateway +Lambda + DynamoDB + S3
  • 25.
    API Gateway +Lambda + DynamoDB + S3 + Cognito
  • 26.
  • 27.
    Simple Storage Service(browser) function addPhoto(albumName) { var files = document.getElementById('photoupload').files; if (!files.length) { return alert('Please choose a file to upload first.'); } var file = files[0]; var fileName = file.name; var albumPhotosKey = encodeURIComponent(albumName) + '//'; var photoKey = albumPhotosKey + fileName; s3.upload({ Key: photoKey, Body: file, ACL: 'public-read' }, function(err, data) { if (err) { return alert('There was an error uploading your photo: ', err.message); } alert('Successfully uploaded photo.'); viewAlbum(albumName); }); }
  • 28.
    API Gateway +Lambda + DynamoDB + S3 + Cognito
  • 30.
    Access to reservedrows and/or columns in DynamoDB
  • 31.
    API Gateway +Lambda + DynamoDB + S3 + Cognito
  • 32.
  • 35.
    ➢ Really scalable ➢Pay per use ➢ Understand new techs ➢ Deploy new architectures API Serverless
  • 36.
    Atomic pricing You cancalculate the exact price of each operation on cloud
  • 37.
    How to moveto serverless pattern ➢ choose right services ➢ define a roadmap ➢ code
  • 38.
    Thanks for listening. AWSomeDay - Torino 2018 - gabriele.mittica@corley.it