© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Orr Weinstein, Sr. Product Manager, AWS Lambda
12/01/2016
ALM in a Serverless WorldSVR307
Common use cases
Web
Applications
Data
Processing
ChatbotsBackends
</></>
Amazon
Alexa
Serverless ALM checklist
• Configuration & management
• Manual deployment
• Automated deployment (CI/CD)
• Tracing & troubleshooting
Serverless application
EVENT SOURCE FUNCTION SERVICES (ANYTHING)
Changes in
data state
Requests to
endpoints
Changes in
resource state
Node.js
Python
Java
C#NEW!
Author Package Test Deploy
AWS Lambda console
IDE plugins
3rd party toolsText editor
ALM – serverless apps
ALM – serverless apps
Author Package Test Deploy
• What if my serverless application consists of dozens or
hundreds of AWS resources?
• What if I have a large dev team?
• Use AWS SAM (powered by CloudFormation)
AWS CloudFormation
• Provision and manage a collection of related AWS
resources.
• Your application = CloudFormation stack
• Input .yaml file and output provisioned AWS resources
AWS Serverless Application Model (SAM)
• CloudFormation extension optimized for serverless
• New serverless resource types: functions, APIs, and
tables
• Supports anything CloudFormation supports
• Open specification (Apache 2.0)
NEW!
SAM template
AWSTemplateFormatVersion: '2010-09-09’Transform: AWS::Serverless-2016-10-31Resources:
GetHtmlFunction:Type: AWS::Serverless::FunctionProperties:
CodeUri: s3://flourish-demo-bucket/todo_list.zipHandler: index.gethtmlRuntime: nodejs4.3Policies: AmazonDynamoDBReadOnlyAccessEvents:
GetHtml:Type: ApiProperties:
Path: /{proxy+}Method: ANY
ListTable:Type: AWS::Serverless::SimpleTable
CloudFormation template
AWSTemplateFormatVersion: '2010-09-09'Resources:GetHtmlFunctionGetHtmlPermissionProd:Type: AWS::Lambda::PermissionProperties:Action: lambda:invokeFunctionPrincipal: apigateway.amazonaws.comFunctionName:Ref: GetHtmlFunction
SourceArn:Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/Prod/ANY/*
ServerlessRestApiProdStage:Type: AWS::ApiGateway::StageProperties:DeploymentId:Ref: ServerlessRestApiDeployment
RestApiId:Ref: ServerlessRestApi
StageName: ProdListTable:Type: AWS::DynamoDB::TableProperties:ProvisionedThroughput:WriteCapacityUnits: 5ReadCapacityUnits: 5
AttributeDefinitions:- AttributeName: idAttributeType: S
KeySchema:- KeyType: HASHAttributeName: id
GetHtmlFunction:Type: AWS::Lambda::FunctionProperties:Handler: index.gethtmlCode:S3Bucket: flourish-demo-bucketS3Key: todo_list.zip
Role:Fn::GetAtt:- GetHtmlFunctionRole- Arn
Runtime: nodejs4.3GetHtmlFunctionRole:Type: AWS::IAM::RoleProperties:ManagedPolicyArns:- arn:aws:iam::aws:policy/AmazonDynamoDBReadOnlyAccess- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
AssumeRolePolicyDocument:Version: '2012-10-17'Statement:- Action:- sts:AssumeRoleEffect: AllowPrincipal:Service:- lambda.amazonaws.com
ServerlessRestApiDeployment:Type: AWS::ApiGateway::DeploymentProperties:RestApiId:Ref: ServerlessRestApi
Description: 'RestApi deployment id: 127e3fb91142ab1ddc5f5446adb094442581a90d'StageName: Stage
GetHtmlFunctionGetHtmlPermissionTest:Type: AWS::Lambda::PermissionProperties:Action: lambda:invokeFunctionPrincipal: apigateway.amazonaws.comFunctionName:Ref: GetHtmlFunction
SourceArn:Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/*/ANY/*
ServerlessRestApi:Type: AWS::ApiGateway::RestApiProperties:Body:info:version: '1.0'title:Ref: AWS::StackName
paths:"/{proxy+}":x-amazon-apigateway-any-method:x-amazon-apigateway-integration:httpMethod: ANYtype: aws_proxyuri:Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-
31/functions/${GetHtmlFunction.Arn}/invocationsresponses: {}
swagger: '2.0'
Serverless ALM checklist
• Configuration & management
• Manual deployment
• Automated deployment (CI/CD)
• Tracing & troubleshooting
AWS commands – Package & Deploy
• Package
• Creates a deployment package (.zip file)
• Uploads deployment package to an Amazon S3 bucket
• Adds a CodeUri property with S3 URI
• Deploy
• Calls CloudFormation ‘CreateChangeSet’ API
• Calls CloudFormation ‘ExecuteChangeSet’ API
NEW!
DEMO 2
Packaging and deploying a SAM
template
Serverless ALM checklist
• Configuration & management
• Manual deployment
• Automated deployment (CI/CD)
• Tracing & troubleshooting
Automated deployment (CI/CD)
AWS CodePipeline
• Continuous delivery service for fast and reliable
application updates
• Model and visualize your software release process
• Builds, tests and deploys your code with every git push
• Integrates with multiple AWS services and 3rd party tools
Source
Source
GitHub
Build
JenkinsOnEC2
Jenkins
Deploy
JavaApp
Elastic Beanstalk
PipelineStageAction
CodePipeline
Source
Source
GitHub
Build
JenkinsOnEC2
Jenkins
Deploy
JavaApp
Elastic Beanstalk
NotifyDevelopers
Lambda
CodePipeline
MyApplication
Parallel actions
Source
Source
GitHub
Build
JenkinsOnEC2
Jenkins
Deploy
JavaApp
Elastic Beanstalk
TestAPI
Runscope
CodePipeline
MyApplication
Sequential actions
Source
Source
GitHub
Build
JenkinsOnEC2
Jenkins
Deploy
JavaApp
Elastic Beanstalk
TestAPI
Runscope
CodePipeline
MyApplication
Transition
Let’s see a serverless pipeline!
But wait…
AWS CodeBuild
• Build and test code in the cloud
• Automatically scales to meet your build volume
• Curated build environments that include runtime and
testing tools for Python, Java, and Node.js
NEW!
Serverless app pipeline
GitHub CodeBuild Ghost inspector
Source Build Beta Test Prod
CloudFormation CloudFormation
DEMO 3
Serverless CI/CD
Serverless ALM checklist
• Configuration & management
• Manual deployment
• Automated deployment (CI/CD)
• Tracing & troubleshooting
Debugging and monitoring
CloudWatch Metrics
• Default (free) metrics:
• Invocations
• Duration
• Throttles
• Errors
• Create custom metrics for
health and status tracking
Metrics and logs
CloudWatch Logs
• Every invocation generates
START, END and REPORT
entries to CW Logs
• Emit your own log entries
• Use 3rd party tools for
aggregation and visualization
X-Ray + Lambda
• Collects data about requests that your application serves
• Provides diagnostic tools
• Visibility into the Lambda service
• Breakdown of your function’s performance
COMING
SOON!
Service map COMING
SOON!
Trace view COMING
SOON!
X-Ray + Lambda
• Service map – identify where your errors or latency
problems are coming from
• Trace view – zoom in to determine the root cause
COMING
SOON!
Serverless ALM checklist
• Configuration & management
• Manual deployment
• Automated deployment (CI/CD)
• Tracing & troubleshooting
Next steps
• Explore the AWS SAM specification on GitHub
• Visit the Lambda console, download a blueprint, and get
started with AWS SAM
• Send us your questions, comments, and feedback on
the AWS Lambda Forums.
Thank you!
Remember to complete
your evaluations!