Serverless Framework
with AWS

Contact
-
github: gwenf
-
twitter: @gwen_faraday
-
email: gwenfaraday@pm.me
Serverless Architecture
Serverless





Lambda
API Gateway
S3
DynamoDB
Cognito
SNS
Event Architecture

Go
Timeline

2014
Lambda

Serverless Framework
2015
API Gateway
2016
AWS Serverless
- Pay per execution
- (almost) No management & configuration

The Serverless Framework
AWS Serverless
- AWS Console
- Zip with aws-cli
- SAM (Serverless Application Model)
The Serverless Framework
- No vendor lock-in
- Large community
- Lot's of examples/plugins
- 3.5 years of development
- Simplified API
Intuitive API
npm i -g serverless
serverless create --template aws-nodejs
serverless deploy
serverless logs
serverless remove
serverless.yml





Installation
npm i -g serverless
sls create --template aws-nodejs --path example1



serverless.yml
service:
name: myAPI
frameworkVersion: ">=1.0.0 <2.0.0"
provider:
name: aws
runtime: nodejs6.10
stage: dev
region: us-east-1
memorySize: 512
timeout: 10serverless.yml
environment:
STAGE: ${self:provider.stage}
VEHICLES_TABLE: vehicles-${self:provider.stage}
LOCATIONS_TABLE: locations-${self:provider.stage}
STATES_TABLE: states-${self:provider.stage}
SKUS_TABLE: skus-${self:provider.stage}
MAKES_TABLE: makes-${self:provider.stage}
MODELS_TABLE: models-${self:provider.stage}serverless.yml
functions:
locations:
handler: lambdas/locations.locations
description: locations lambda
events:
- http:
path: api/locations
method: get
cors: true
- http:
path: api/locations
request: ${self:custom.standardRequest}
integration: lambda
method: post
cors: trueserverless.yml
resources:
Resources:
LocationsTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.LOCATIONS_TABLE}Debugging
1. CloudWatch logs in the AWS console
2. CloudWatch logs from the AWS CLI
3. Third party logging software

sls logs -f hello -teg Librato
Local Testing
-
Zip and Upload, then Test
-
Command Line
-
Testing Frameworks (example)

Resources
Contact
-
github: gwenf
-
twitter: @gwen_faraday
-
email: gwenfaraday@pm.me
deck
By gwenf
deck
- 595