35
© 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 World SVR307

AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Embed Size (px)

Citation preview

Page 1: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

© 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

Page 2: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Common use cases

Web

Applications

Data

Processing

ChatbotsBackends

</></>

Amazon

Alexa

Page 3: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Serverless ALM checklist

• Configuration & management

• Manual deployment

• Automated deployment (CI/CD)

• Tracing & troubleshooting

Page 4: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Serverless application

EVENT SOURCE FUNCTION SERVICES (ANYTHING)

Changes in

data state

Requests to

endpoints

Changes in

resource state

Node.js

Python

Java

C#NEW!

Page 5: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Author Package Test Deploy

AWS Lambda console

IDE plugins

3rd party toolsText editor

ALM – serverless apps

Page 6: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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)

Page 7: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

AWS CloudFormation

• Provision and manage a collection of related AWS

resources.

• Your application = CloudFormation stack

• Input .yaml file and output provisioned AWS resources

Page 8: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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!

Page 9: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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

Page 10: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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'

Page 11: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Serverless ALM checklist

• Configuration & management

• Manual deployment

• Automated deployment (CI/CD)

• Tracing & troubleshooting

Page 12: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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!

Page 13: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

DEMO 2

Packaging and deploying a SAM

template

Page 14: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Serverless ALM checklist

• Configuration & management

• Manual deployment

• Automated deployment (CI/CD)

• Tracing & troubleshooting

Page 15: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Automated deployment (CI/CD)

Page 16: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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

Page 17: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Source

Source

GitHub

Build

JenkinsOnEC2

Jenkins

Deploy

JavaApp

Elastic Beanstalk

PipelineStageAction

CodePipeline

Page 18: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Source

Source

GitHub

Build

JenkinsOnEC2

Jenkins

Deploy

JavaApp

Elastic Beanstalk

NotifyDevelopers

Lambda

CodePipeline

MyApplication

Parallel actions

Page 19: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Source

Source

GitHub

Build

JenkinsOnEC2

Jenkins

Deploy

JavaApp

Elastic Beanstalk

TestAPI

Runscope

CodePipeline

MyApplication

Sequential actions

Page 20: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Source

Source

GitHub

Build

JenkinsOnEC2

Jenkins

Deploy

JavaApp

Elastic Beanstalk

TestAPI

Runscope

CodePipeline

MyApplication

Transition

Page 21: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Let’s see a serverless pipeline!

But wait…

Page 22: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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!

Page 23: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Serverless app pipeline

GitHub CodeBuild Ghost inspector

Source Build Beta Test Prod

CloudFormation CloudFormation

Page 24: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

DEMO 3

Serverless CI/CD

Page 25: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Serverless ALM checklist

• Configuration & management

• Manual deployment

• Automated deployment (CI/CD)

• Tracing & troubleshooting

Page 26: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Debugging and monitoring

Page 27: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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

Page 28: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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!

Page 29: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Service map COMING

SOON!

Page 30: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Trace view COMING

SOON!

Page 31: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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!

Page 32: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Serverless ALM checklist

• Configuration & management

• Manual deployment

• Automated deployment (CI/CD)

• Tracing & troubleshooting

Page 33: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

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.

Page 34: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Thank you!

Page 35: AWS re:Invent 2016: Application Lifecycle Management in a Serverless World (SVR307)

Remember to complete

your evaluations!