@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
Building block of Serverless Architecture
Stateless and ephemeral
Functions run in containers that you don't manage
Removed complexity of building infrastructure
You only pay for the functions that you use
@lynnaloo
@lynnaloo
@lynnaloo
Storage
IoT
Database Actions
API Gateway
Queues and Topics
Logging
@lynnaloo
Responsible for one specific task
Lightweight and fast
Reusable
Deployed independently
Not dependent on other services
Work together to power applications
@lynnaloo
@lynnaloo
@lynnaloo
Dedicated
Flexible
Supportive
Resilient
Growth potential
Speaks many languages!
@lynnaloo
@lynnaloo
@lynnaloo
Open-source
Abstracts and automates provider-specific tasks
Multi-provider plugin system
Scaffold and deploy using CLI
@lynnaloo
# Install serverless cli
$ npm install serverless -g
# Create AWS Service
$ serverless create --template aws-nodejs --path cat-name-service
# Change into the service directory
$ cd cat-name-service
# Deploy to cloud provider
$ serverless deploy -v
cat-name-service/
package.json
serverless.yml
handler.js
dog-name-service/
package.json
serverless.yml
handler.js
@lynnaloo
#serverless.yml
service: cat-name-service
provider:
name: aws
runtime: nodejs6.10
functions:
catName:
handler: handler.getCatName
events:
- http:
path: cats/name
method: get
@lynnaloo
'use strict';
const catNames = require('cat-names');
function getCatName(event, context, callback) {
callback(null, { payload: `Your cat name is ${catNames.random()}.` });
}
module.exports.getCatName;
@lynnaloo
'use strict';
const catNames = require('cat-names');
const AmazonDb = require('amazon-db-module');
function getCatName(event, context, callback) {
const amazonDb = new AmazonDb();
const catName = catNames.random();
amazonDb.update(catName);
callback(null, { payload: `Your cat name is ${catName}.` });
}
module.exports.getCatName;
'use strict';
const catNames = require('cat-names');
const GoogleDb = require('google-db-module');
function getCatName(request, response) {
const googleDb = new GoogleDb();
const catName = catNames.random();
googleDb.update(catName);
return response.status(200).send(`Your cat name is ${catName}.`);
}
module.exports.getCatName;
@lynnaloo
@lynnaloo
github.com/lynnaloo/valentines-day-bot
Mention @thesecatstweet in a tweet with the hashtag #happyvalentinebot
@lynnaloo
github.com/lynnaloo/valentines-day-bot