Beginning
Serverless
Applications
With
AWS SAM
@Harprits
@NewsServerless
harprit
#01
An Overview
Serverless
002
#02
A Developer’s View
06
Serverless
Applications
007
FaaSEvents BaaS
#03
AWS SAM – a framework for
building and managing
Serverless applications.
AWS
Serverless
Application
Model
08
09
Organize architectural
components of your serverless
application at one place.
SAM TEMPLATE
010
Manage lifecycle of your
serverless application with one
tool.
SAM CLI
011
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: target/helloworldsam-1.0.jar
Handler: com.Helloworldsam.App::handleRequest
Runtime: java8
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello/{name}
Method: get
HelloWorldTable:
Type: AWS::Serverless::SimpleTable
Transform
Cloudformation
FaaS
Lambda
Event
API Gateway
Serverless Resource
DynamoDB Table
012
AWS::Serverless::Function
AWS::Serverless::Api
AWS::Serverless::SimpleTable
AWS::Serverless::Application
AWS::Serverless::LayerVersion
Serverless
Specific
Resources
013
Api
SNS
Schedule
SQS
Kinesis
DynamoDB
S3
CloudWatchEvent
CloudWatchLogs
IoTRule
AlexaSkill
Event
Sources Type: Api
Properties:
Path: /photos
Method: post
Type: S3
Properties:
Bucket: my-bucket
Events: s3:ObjectCreated:*
014
SAM
CLI
Commands
sam init
sam validate
sam build
sam local generate-event
sam local invoke
sam local start-api
sam local start-lambda
sam logs
sam package
sam deploy
sam publish
015
Local Testing and Debugging
sam local
AWS Ecosystem
Services, SAR, Cloud9
Serverless Friendly Cloudformation
one less thing to learn
Safe Lambda Deployments
CanaryXPercentYMinutes vs LinearXPercentEveryYMinutes
Why
SAM?
016
MyLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs6.10
AutoPublishAlias: live
DeploymentPreference:
Type: LinearXPercentEveryYMinutes
Traffic to new version will linearly increase in steps of X percentage every Y minutes. Ex:
Linear10PercentEvery10Minutes will add 10 percentage of traffic every 10 minute to complete in 100
minutes.
Type: CanaryXPercentYMinutes
X percent of traffic will be routed to new version for Y minutes. After Y minutes, 100 percent of traffic will be
sent to new version. Some people call this as Blue/Green deployment. Ex: Canary10Percent15Minutes will
send 10 percent traffic to new version and 15 minutes later complete deployment by sending all traffic to
new version.
Type: AllAtOnce
017
Demo

Beginning Serverless Applications with AWS SAM