SlideShare a Scribd company logo
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Building CI/CD Pipelines for Serverless
Applications
Prakash Palanisamy, Solutions Architect | 11th Oct, 2018
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Serverless application
SERVICES (ANYTHING)
Changes in
data state
Requests to
endpoints
Changes in
resource state
EVENT SOURCE FUNCTION
Node.js
Python
Java
C#
GO
PowerShell
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon S3 Amazon
DynamoDB
Amazon
Kinesis
AWS
CloudFormation
AWS CloudTrail Amazon
CloudWatch
Amazon
Cognito
Cron events
DATA STORES ENDPOINTS
DEVELOPMENT AND MANAGEMENT TOOLS EVENT/MESSAGE SERVICES
Example event sources that trigger AWS Lambda
… and a few more with more on the way!
AWS
CodeCommit
AWS IoT AWS Step
Functions
Amazon
Alexa
Amazon
SES
Amazon
SQS
Amazon
SNS
Amazon
API Gateway
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Understanding “CI & CD”
Source Build Test Production
Continuous integration
Continuous delivery
Continuous deployment
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CI/CD for serverless applications
There are a number of different paradigms we need to take
into account when doing CI&CD for serverless applications:
• Lambda functions are a unit of deployment
• We’ll typically have multiple Lambda functions per application
• Each function will have an event trigger
• Could be shared or unique to each function
• A serverless application is typically a combination of AWS Lambda +
other AWS services
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CI/CD for serverless applications
We’ll want to deliver our serverless application via a
traditional development pipeline:
• Pipeline initiated after code is committed to a repository
• Built, tested, and verified at the code level exactly once
• Aim for single artifact per deploy
• Integration tested at functional and end-to-end levels
• Deployed to independent environments for each stage of this process
• Allow for those independent environments to be deployed exactly the
same way across infrastructure + application
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Development Workflow Checklist
q Model your application and infrastructure resources
q Configure multiple environments
q Automate your delivery process
q Collect metrics and logs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
An example of services for building serverless applications:
Best practice: Manage these AWS resources with “Infrastructure as Code”
practices/tools!
Amazon S3 Amazon
DynamoDB
AWS Step
Functions
Amazon
SQS
Amazon
SNS
Amazon
API Gateway
Amazon
Kinesis
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Create templates of your infrastructure
CloudFormation provisions AWS resources
based on dependency needs
Version control/replicate/update templates like
code
Integrates with development, CI/CD,
management tools
JSON and YAML supported
AWS CloudFormation
Create templates of your infrastructure
CloudFormation provisions AWS resources
based on dependency needs
Version control/replicate/update templates
like code
Integrates with development, CI/CD,
management tools
JSON and YAML supported
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CloudFormation template
AWSTemplateFormatVersion: '2010-09-09'
Resources:
GetHtmlFunctionGetHtmlPermissionProd:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:invokeFunction
Principal: apigateway.amazonaws.com
FunctionName:
Ref: GetHtmlFunction
SourceArn:
Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/Prod/ANY/*
ServerlessRestApiProdStage:
Type: AWS::ApiGateway::Stage
Properties:
DeploymentId:
Ref: ServerlessRestApiDeployment
RestApiId:
Ref: ServerlessRestApi
StageName: Prod
ListTable:
Type: AWS::DynamoDB::Table
Properties:
ProvisionedThroughput:
WriteCapacityUnits: 5
ReadCapacityUnits: 5
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- KeyType: HASH
AttributeName: id
GetHtmlFunction:
Type: AWS::Lambda::Function
Properties:
Handler: index.gethtml
Code:
S3Bucket: flourish-demo-bucket
S3Key: todo_list.zip
Role:
Fn::GetAtt:
- GetHtmlFunctionRole
- Arn
Runtime: nodejs4.3
GetHtmlFunctionRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonDynamoDBReadOnlyAccess
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
ServerlessRestApiDeployment:
Type: AWS::ApiGateway::Deployment
Properties:
RestApiId:
Ref: ServerlessRestApi
Description: 'RestApi deployment id: 127e3fb91142ab1ddc5f5446adb094442581a90d'
StageName: Stage
GetHtmlFunctionGetHtmlPermissionTest:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:invokeFunction
Principal: apigateway.amazonaws.com
FunctionName:
Ref: GetHtmlFunction
SourceArn:
Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/*/ANY/*
ServerlessRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Body:
info:
version: '1.0'
title:
Ref: AWS::StackName
paths:
"/{proxy+}":
x-amazon-apigateway-any-method:
x-amazon-apigateway-integration:
httpMethod: ANY
type: aws_proxy
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-
31/functions/${GetHtmlFunction.Arn}/invocations
responses: {}
swagger: '2.0'
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CloudFormation template
AWSTemplateFormatVersion: '2010-09-09'
Resources:
GetHtmlFunctionGetHtmlPermissionProd:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:invokeFunction
Principal: apigateway.amazonaws.com
FunctionName:
Ref: GetHtmlFunction
SourceArn:
Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/Prod/ANY/*
ServerlessRestApiProdStage:
Type: AWS::ApiGateway::Stage
Properties:
DeploymentId:
Ref: ServerlessRestApiDeployment
RestApiId:
Ref: ServerlessRestApi
StageName: Prod
ListTable:
Type: AWS::DynamoDB::Table
Properties:
ProvisionedThroughput:
WriteCapacityUnits: 5
ReadCapacityUnits: 5
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- KeyType: HASH
AttributeName: id
GetHtmlFunction:
Type: AWS::Lambda::Function
Properties:
Handler: index.gethtml
Code:
S3Bucket: flourish-demo-bucket
S3Key: todo_list.zip
Role:
Fn::GetAtt:
- GetHtmlFunctionRole
- Arn
Runtime: nodejs4.3
GetHtmlFunctionRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonDynamoDBReadOnlyAccess
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
ServerlessRestApiDeployment:
Type: AWS::ApiGateway::Deployment
Properties:
RestApiId:
Ref: ServerlessRestApi
Description: 'RestApi deployment id: 127e3fb91142ab1ddc5f5446adb094442581a90d'
StageName: Stage
GetHtmlFunctionGetHtmlPermissionTest:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:invokeFunction
Principal: apigateway.amazonaws.com
FunctionName:
Ref: GetHtmlFunction
SourceArn:
Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/*/ANY/*
ServerlessRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Body:
info:
version: '1.0'
title:
Ref: AWS::StackName
paths:
"/{proxy+}":
x-amazon-apigateway-any-method:
x-amazon-apigateway-integration:
httpMethod: ANY
type: aws_proxy
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-
31/functions/${GetHtmlFunction.Arn}/invocations
responses: {}
swagger: '2.0'
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
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)
https://github.com/awslabs/serverless-application-model
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM template
AWSTemplateFormatVersion: '2010-09-09’
Transform: AWS::Serverless-2016-10-31
Resources:
GetHtmlFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/todo_list.zip
Handler: index.gethtml
Runtime: nodejs4.3
Policies: AmazonDynamoDBReadOnlyAccess
Events:
GetHtml:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
ListTable:
Type: AWS::Serverless::SimpleTable
Tells CloudFormation that this is a
SAM template it needs to “transform”
Creates a Lambda function with the
referenced managed IAM policy,
runtime, code at the referenced zip
location, and handler as defined.
Also creates an API Gateway and
takes care of all
mapping/permissions necessary
Creates a DynamoDB table with 5
Read & Write units
Tells CloudFormation that this is a
SAM template it needs to “transform”
Creates a Lambda function with the
referenced managed IAM policy,
runtime, code at the referenced zip
location, and handler as defined.
Also creates an API Gateway and
takes care of all
mapping/permissions necessary
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM template
From: https://github.com/awslabs/aws-serverless-samfarm/blob/master/api/saml.yaml
<-THIS
BECOMES THIS->
From: https://github.com/awslabs/aws-serverless-samfarm/blob/master/api/saml.yaml
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM template properties
AWS::Serverless::Function
AWS::Serverless::Api
AWS::Serverless::SimpleTable
Starting SAM Version 2016-10-31
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM template properties
AWS::Serverless::Function
AWS::Serverless::Api
AWS::Serverless::SimpleTable
Starting SAM Version 2016-10-31
Handler: index.js
Runtime: nodejs4.3
CodeUri: 's3://my-code-bucket/my-
function.zip'
Description: Creates thumbnails of uploaded
images
MemorySize: 1024
Timeout: 15
Policies: AmazonS3FullAccess
Environment:
Variables:
TABLE_NAME: my-table
Events:
PhotoUpload:
Type: S3
Properties:
Bucket: my-photo-bucket
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM template properties
AWS::Serverless::Function
AWS::Serverless::Api
AWS::Serverless::SimpleTable
From SAM Version 2016-10-31
StageName: prod
DefinitionUri: swagger.yml
CacheClusterEnabled: true
CacheClusterSize: 28.4
Variables:
VarName: VarValue
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM template properties
AWS::Serverless::Function
AWS::Serverless::Api
AWS::Serverless::SimpleTable
From SAM Version 2016-10-31
PrimaryKey:
Name: id
Type: String
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM template capabilities
• Can mix in other non-SAM CloudFormation resources in
the same template
• Examples: Amazon S3, Amazon Kinesis, AWS Step Functions
• Supports use of parameters, mappings, outputs, etc.
• Supports intrinsic functions
• Can use ImportValue
(exceptions for RestApiId, Policies, StageName attributes)
• YAML or JSON
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
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
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Development Workflow Checklist
ü Model your application and infrastructure resources
q Configure multiple environments
q Automate your delivery process
q Collect metrics and logs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Configure multiple environments
Good developers know they need different environments for building,
testing, and running their applications!
Why?
• Avoid overlapping usage of resources
• Safely test new code without impacting your customers
• Safely test infrastructure changes
How?
• AWS account strategies
• Using infrastructure as code tools
• Using variables unique to each environment
• Automating application delivery/testing
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Configure multiple environments
Same account, different stacks:
+ Easier management of resources
+ Easier visibility via
management/monitoring tools
- Can be harder to create
permission/access separation
Better for smaller teams/individuals
Two popular AWS account strategies:
Multiple accounts:
+ Assured separation of permissions
and access
+ Resource limits per account to
control usage
- Overhead of managing multiple
accounts and controls between them
Better for larger teams/companies
Check out AWS Organizations
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Environment Variables
• Key-value pairs that you can dynamically pass to your
function
• Available via standard environment variable APIs such as
process.env for Node.js or os.environ for Python
• Can optionally be encrypted via KMS
• Allows you to specify in IAM what roles have access to the keys to decrypt the
information
• Useful for creating environments per stage (such as dev,
testing, production)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
API Gateway Stage Variables
• Stage variables act like environment variables
• Use stage variables to store configuration values
• Stage variables are available in the $context object
• Values are accessible from most fields in API Gateway
• Lambda function ARN
• HTTP endpoint
• Custom authorizer function name
• Parameter mappings
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Template File
Defining Stack
Source
Control
Dev
Test
Prod
Use the version
control system of
your choice to store
and track changes
to this template
Build out multiple
environments, such as
for development, test,
production and even
DR using the same
template, even across
accounts
Many environments from one template
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda and API Gateway Variables + SAM
Parameters:
MyEnvironment:
Type: String
Default: testing
AllowedValues:
- testing
- staging
- prod
Description: Environment of this stack of
resources
SpecialFeature1:
Type: String
Default: false
AllowedValues:
- true
- false
Description: Enable new SpecialFeature1
…
#Lambda
MyFunction:
Type: 'AWS::Serverless::Function'
Properties:
…
Environment:
Variables:
ENVIRONMENT: !Ref: MyEnvironment
Spec_Feature1: !Ref: SpecialFeature1
…
#API Gateway
MyApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
…
Variables:
ENVIRONMENT: !Ref: MyEnvironment
SPEC_Feature1: !Ref: SpecialFeature1
…
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Development Workflow Checklist
ü Model your application and infrastructure resources
ü Configure multiple environments
q Automate your delivery process
q Collect metrics and logs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Building a deployment package
Node.js & Python
• .zip file consisting of
your code and any
dependencies
• Use npm/pip to install
libraries
• All dependencies must
be at root level
Java
• Either .zip file with all
code/dependencies, or
standalone .jar
• Use Maven / Eclipse IDE
plugins
• Compiled class & resource
files at root level, required
jars in /lib directory
C# (.NET Core)
• Either .zip file with all
code/dependencies, or
a standalone .dll
• Use NuGet /
VisualStudio plugins
• All assemblies (.dll) at
root level
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Building a deployment package
GO
• .zip file consisting of your code
and any dependencies using
build-lambda-zip
• Use go get to download the
libraries
• All dependencies must be at
root level
PowerShell
• .zip file with all
code/dependencies.
• Use NuGet and PowerShell
Cmd-let
New-AWSPowerShellLambdaPa
ckage
• All dependencies at root level
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Fully managed build service that compiles source code, runs
tests, and produces software packages
Scales continuously and processes multiple builds concurrently
You can provide custom build environments suited to your
needs via Docker images
Only pay by the minute for the compute resources you use
Launched with AWS CodePipeline and Jenkins integration
Can be used as a “Test” action in CodePipeline
AWS CodeBuild
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Variables to be used by phases
of build
• Examples for what you can do in
the phases of a build:
• You can install packages or run
commands to prepare your
environment in “install”.
• Run syntax checking,
commands in “pre_build”.
• Execute your build
tool/command in “build”
• Test your app further or ship a
container image to a repository
in post_build
• Create and store an artifact in S3
buildspec.yml Exampleversion: 0.1
environment_variables:
plaintext:
"INPUT_FILE": "saml.yaml”
"S3_BUCKET": ""
phases:
install:
commands:
- npm install
pre_build:
commands:
- eslint *.js
build:
commands:
- npm test
post_build:
commands:
- aws cloudformation package --template $INPUT_FILE --s3-
bucket $S3_BUCKET --output-template post-saml.yaml
artifacts:
type: zip
files:
- post-saml.yaml
- beta.json
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Establish our testing/validation model
We want to make sure our code:
• Is without syntax issues
• Meets company standards for format
• Compiles
• Is sufficiently tested at the code level via unit tests
We want to make sure our serverless service:
• Functions as it is supposed to in relation to other components
• Has appropriate mechanisms to handle failures up or down stream
We want to make sure our entire application/infrastructure:
• Functions end to end
• Follows security best practices
• Handles scaling demands
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Automates code deployments to any instance
Handles the complexity of updating your
applications
Avoid downtime during application deployment
Rollback automatically if failure detected
Deploy to Amazon EC2 or on-premises servers, in
any language and on any operating system
Integrates with third-party tools and AWS
AWS CodeDeploy
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM Globals + Safe Deployments
Globals:
Function:
Runtime: nodejs4.3
AutoPublishAlias: !Ref ENVIRONMENT
MyLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
DeploymentPreference:
Type: Linear10PercentEvery10Minutes
Alarms:
# A list of alarms that you want to monitor
- !Ref AliasErrorMetricGreaterThanZeroAlarm
- !Ref LatestVersionErrorMetricGreaterThanZeroAlarm
Hooks:
# Validation Lambda functions that are run before & after traffic shifting
PreTraffic: !Ref PreTrafficLambdaFunction
PostTraffic: !Ref PostTrafficLambdaFunction
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Alias Traffic Shifting & AWS SAM
In SAM:
Note: You can specify a maximum of 10 alarms
Alarms: # A list of alarms that you want to monitor
- !Ref AliasErrorMetricGreaterThanZeroAlarm
- !Ref LatestVersionErrorMetricGreaterThanZeroAlarm
Hooks: # Validation Lambda functions that are run
before & after traffic shifting
PreTraffic: !Ref PreTrafficLambdaFunction
PostTraffic: !Ref PostTrafficLambdaFunction
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon API Gateway Canary Support
Use canary release deployments to gradually roll out new
APIs in Amazon API Gateway:
• configure percent of traffic to go to a new stage
deployment
• can test stage settings and variables
• API gateway will create additional Amazon CloudWatch
Logs group and CloudWatch metrics for the requests
handled by the canary deployment API
• To rollback: delete the deployment or set percent of
traffic to 0
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Continuous delivery service for fast and
reliable application updates
Model and visualize your software release
process
Builds, tests, and deploys your code every
time there is a code change
Integrates with third-party tools and AWS
AWS CodePipeline
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Delivery via AWS CodePipeline
Pipeline flow:
1. Commit your code to a source code repository
2. Package/test in AWS CodeBuild
3. Use CloudFormation actions in AWS CodePipeline
to create or update stacks via SAM templates
Optional: Make use of ChangeSets
4. Make use of specific stage/environment parameter
files to pass in AWS Lambda variables
5. Test our application between stages/environments
Optional: Make use of manual approvals
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CodePipeline + CloudFormation Parameters
Via referenced parameter file: Via Parameter Overrides:
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CodePipeline + CloudFormation Parameters
Via referenced parameter file:
Pros:
• Allows developers to update and provide
parameters via file in the code repository
• Easier to change and iterate via
deployment
Cons:
• Potentially harder to control security or
confidential information passed in
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CodePipeline + CloudFormation Parameters
Via Parameter Overrides:Pros:
• Tighter control over parameters
passed in
• Can restrict access to information
based on visibility to CodePipeline and
CloudFormation
Cons:
• Modification requires a change to the
pipeline and a re-execution
• Harder to track the changes to these
values unless you are tracking them
via CloudFormation to manage the
pipeline(as an example)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Source
Source
CodeCommit
MyApplication
An example minimal pipeline:
Build
test-build-source
CodeBuild
Deploy Testing
create-changeset
AWS
CloudFormation
execute-changeset
AWS
CloudFormation
Run-stubs
AWS Lambda
Deploy Staging
create-changeset
AWS
CloudFormation
execute-changeset
AWS
CloudFormation
Run-API-test
Runscope
QA-Sign-off
Manual Approval
Review
Deploy Prod
create-changeset
AWS
CloudFormation
execute-changeset
AWS
CloudFormation
Post-Deploy-Slack
AWS Lambda
This pipeline:
• Five stages
• Builds code artifact
• Three deployed to
“environments”
• Uses CloudFormation to deploy
artifact and other AWS resources
• Has Lambda custom actions for
running my own testing functions
• Integrates with a third-party
tool/service
• Has a manual approval before
deploying to production
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Code Services
Source Build Test Production
Third-Party
Tooling
Software Release Steps:
AWS CodeCommit AWS CodeBuild AWS CodeDeploy
AWS CodePipeline
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Development Workflow Checklist
ü Model your application and infrastructure resources
ü Configure multiple environments
ü Automate your delivery process
q Collect metrics and logs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Metrics and logs
• Default (free) metrics:
• Invocations
• Duration
• Throttles
• Errors
• Create custom metrics for
health and status tracking
CloudWatch Metrics CloudWatch Logs
• Every invocation generates
START, END and REPORT
entries to CW Logs
• Emit your own log entries
• Use third-party tools for
aggregation and visualization
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray + AWS Lambda
• Collects data about requests that your application serves
• Provides diagnostic tools
• Visibility into the AWS Lambda service
• Breakdown of your function’s performance
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Service map
Identify where your errors or latency problems are coming from
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Trace view
Zoom in to determine the root cause
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
DEMO!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
aws.amazon.com/serverless
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
aws.amazon.com/serverless/developer-tools
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Additional resources
Serverless Application Model (SAM) - https://github.com/awslabs/serverless-
application-model
Learn more:
AWS Lambda: https://aws.amazon.com/lambda
Amazon API Gateway: https://aws.amazon.com/api-gateway
Products that helped us today:
AWS CloudFormation: https://aws.amazon.com/cloudformation
AWS CodePipeline: https://aws.amazon.com/codepipeline
AWS CodeDeploy: https://aws.amazon.com/codedeploy/
AWS CodeBuild: https://aws.amazon.com/codebuild
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!!!

More Related Content

What's hot

Introduction to Tekton
Introduction to TektonIntroduction to Tekton
Introduction to Tekton
Victor Iglesias
 
Power of Azure Devops
Power of Azure DevopsPower of Azure Devops
Power of Azure Devops
Azure Riyadh User Group
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
Knoldus Inc.
 
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
HostedbyConfluent
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
Julian Mazzitelli
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CI
David Hahn
 
Clean Infrastructure as Code
Clean Infrastructure as Code Clean Infrastructure as Code
Clean Infrastructure as Code
QAware GmbH
 
Cloud-Native CI/CD on Kubernetes with Tekton Pipelines
Cloud-Native CI/CD on Kubernetes with Tekton PipelinesCloud-Native CI/CD on Kubernetes with Tekton Pipelines
Cloud-Native CI/CD on Kubernetes with Tekton Pipelines
Nikhil Thomas
 
Gitops: the kubernetes way
Gitops: the kubernetes wayGitops: the kubernetes way
Gitops: the kubernetes way
sparkfabrik
 
CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton
Araf Karsh Hamid
 
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
Hyperledger Korea User Group
 
Scaling DevSecOps Culture for Enterprise
Scaling DevSecOps Culture for EnterpriseScaling DevSecOps Culture for Enterprise
Scaling DevSecOps Culture for Enterprise
Opsta
 
DevOps 101
DevOps 101DevOps 101
DevOps 101
Ernest Mueller
 
Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...
Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...
Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...
Codit
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Edureka!
 
Kubernetes Architecture
 Kubernetes Architecture Kubernetes Architecture
Kubernetes Architecture
Knoldus Inc.
 
Secrets in Kubernetes
Secrets in KubernetesSecrets in Kubernetes
Secrets in Kubernetes
Jerry Jalava
 
Observability
ObservabilityObservability
Observability
Ebru Cucen Çüçen
 
Free GitOps Workshop + Intro to Kubernetes & GitOps
Free GitOps Workshop + Intro to Kubernetes & GitOpsFree GitOps Workshop + Intro to Kubernetes & GitOps
Free GitOps Workshop + Intro to Kubernetes & GitOps
Weaveworks
 
Supercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Supercharging CI/CD with GitLab and Rancher - June 2017 Online MeetupSupercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Supercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Shannon Williams
 

What's hot (20)

Introduction to Tekton
Introduction to TektonIntroduction to Tekton
Introduction to Tekton
 
Power of Azure Devops
Power of Azure DevopsPower of Azure Devops
Power of Azure Devops
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CI
 
Clean Infrastructure as Code
Clean Infrastructure as Code Clean Infrastructure as Code
Clean Infrastructure as Code
 
Cloud-Native CI/CD on Kubernetes with Tekton Pipelines
Cloud-Native CI/CD on Kubernetes with Tekton PipelinesCloud-Native CI/CD on Kubernetes with Tekton Pipelines
Cloud-Native CI/CD on Kubernetes with Tekton Pipelines
 
Gitops: the kubernetes way
Gitops: the kubernetes wayGitops: the kubernetes way
Gitops: the kubernetes way
 
CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton
 
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
 
Scaling DevSecOps Culture for Enterprise
Scaling DevSecOps Culture for EnterpriseScaling DevSecOps Culture for Enterprise
Scaling DevSecOps Culture for Enterprise
 
DevOps 101
DevOps 101DevOps 101
DevOps 101
 
Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...
Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...
Application Autoscaling Made Easy with Kubernetes Event-Driven Autoscaling (K...
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
 
Kubernetes Architecture
 Kubernetes Architecture Kubernetes Architecture
Kubernetes Architecture
 
Secrets in Kubernetes
Secrets in KubernetesSecrets in Kubernetes
Secrets in Kubernetes
 
Observability
ObservabilityObservability
Observability
 
Free GitOps Workshop + Intro to Kubernetes & GitOps
Free GitOps Workshop + Intro to Kubernetes & GitOpsFree GitOps Workshop + Intro to Kubernetes & GitOps
Free GitOps Workshop + Intro to Kubernetes & GitOps
 
Supercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Supercharging CI/CD with GitLab and Rancher - June 2017 Online MeetupSupercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Supercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
 

Similar to Building CICD Pipelines for Serverless Applications

Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
Amazon Web Services
 
Serverless Developer Experience I AWS Dev Day 2018
Serverless Developer Experience I AWS Dev Day 2018Serverless Developer Experience I AWS Dev Day 2018
Serverless Developer Experience I AWS Dev Day 2018
AWS Germany
 
Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
Amazon Web Services
 
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017Amazon Web Services
 
Raleigh DevDay 2017: Building CICD pipelines for serverless applications
Raleigh DevDay 2017: Building CICD pipelines for serverless applicationsRaleigh DevDay 2017: Building CICD pipelines for serverless applications
Raleigh DevDay 2017: Building CICD pipelines for serverless applications
Amazon Web Services
 
SMC305 Building CI/CD Pipelines for Serverless Applications
SMC305 Building CI/CD Pipelines for Serverless ApplicationsSMC305 Building CI/CD Pipelines for Serverless Applications
SMC305 Building CI/CD Pipelines for Serverless Applications
Amazon Web Services
 
Build and Deploy Serverless Applications with AWS SAM
Build and Deploy Serverless Applications with AWS SAM Build and Deploy Serverless Applications with AWS SAM
Build and Deploy Serverless Applications with AWS SAM
Amazon Web Services
 
Serverless Applications with AWS SAM
Serverless Applications with AWS SAMServerless Applications with AWS SAM
Serverless Applications with AWS SAM
Chris Munns
 
Productionize Serverless Application Building and Deployments with AWS SAM - ...
Productionize Serverless Application Building and Deployments with AWS SAM - ...Productionize Serverless Application Building and Deployments with AWS SAM - ...
Productionize Serverless Application Building and Deployments with AWS SAM - ...
Amazon Web Services
 
Best Practices for CI/CD with AWS Lambda and Amazon API Gateway (SRV355-R1) -...
Best Practices for CI/CD with AWS Lambda and Amazon API Gateway (SRV355-R1) -...Best Practices for CI/CD with AWS Lambda and Amazon API Gateway (SRV355-R1) -...
Best Practices for CI/CD with AWS Lambda and Amazon API Gateway (SRV355-R1) -...
Amazon Web Services
 
Devops on serverless
Devops on serverlessDevops on serverless
Devops on serverless
Sébastien ☁ Stormacq
 
Application Lifecycle Management in a Serverless World | AWS Public Sector Su...
Application Lifecycle Management in a Serverless World | AWS Public Sector Su...Application Lifecycle Management in a Serverless World | AWS Public Sector Su...
Application Lifecycle Management in a Serverless World | AWS Public Sector Su...
Amazon Web Services
 
Deep Dive on Serverless Application Development
Deep Dive on Serverless Application DevelopmentDeep Dive on Serverless Application Development
Deep Dive on Serverless Application Development
Amazon Web Services
 
Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...
Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...
Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...
Amazon Web Services
 
Serverless Functions Deep Dive
Serverless Functions Deep DiveServerless Functions Deep Dive
Serverless Functions Deep Dive
Amazon Web Services
 
Serverless functions deep dive
Serverless functions deep diveServerless functions deep dive
Serverless functions deep dive
Amazon Web Services
 
Deep Dive On Serverless App Development
Deep Dive On Serverless App DevelopmentDeep Dive On Serverless App Development
Deep Dive On Serverless App Development
Amazon Web Services
 
Deep Dive on Serverless App Development
Deep Dive on Serverless App DevelopmentDeep Dive on Serverless App Development
Deep Dive on Serverless App Development
Amazon Web Services
 
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
Amazon Web Services
 
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS SummitBuilding serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
Amazon Web Services
 

Similar to Building CICD Pipelines for Serverless Applications (20)

Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
 
Serverless Developer Experience I AWS Dev Day 2018
Serverless Developer Experience I AWS Dev Day 2018Serverless Developer Experience I AWS Dev Day 2018
Serverless Developer Experience I AWS Dev Day 2018
 
Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
 
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
 
Raleigh DevDay 2017: Building CICD pipelines for serverless applications
Raleigh DevDay 2017: Building CICD pipelines for serverless applicationsRaleigh DevDay 2017: Building CICD pipelines for serverless applications
Raleigh DevDay 2017: Building CICD pipelines for serverless applications
 
SMC305 Building CI/CD Pipelines for Serverless Applications
SMC305 Building CI/CD Pipelines for Serverless ApplicationsSMC305 Building CI/CD Pipelines for Serverless Applications
SMC305 Building CI/CD Pipelines for Serverless Applications
 
Build and Deploy Serverless Applications with AWS SAM
Build and Deploy Serverless Applications with AWS SAM Build and Deploy Serverless Applications with AWS SAM
Build and Deploy Serverless Applications with AWS SAM
 
Serverless Applications with AWS SAM
Serverless Applications with AWS SAMServerless Applications with AWS SAM
Serverless Applications with AWS SAM
 
Productionize Serverless Application Building and Deployments with AWS SAM - ...
Productionize Serverless Application Building and Deployments with AWS SAM - ...Productionize Serverless Application Building and Deployments with AWS SAM - ...
Productionize Serverless Application Building and Deployments with AWS SAM - ...
 
Best Practices for CI/CD with AWS Lambda and Amazon API Gateway (SRV355-R1) -...
Best Practices for CI/CD with AWS Lambda and Amazon API Gateway (SRV355-R1) -...Best Practices for CI/CD with AWS Lambda and Amazon API Gateway (SRV355-R1) -...
Best Practices for CI/CD with AWS Lambda and Amazon API Gateway (SRV355-R1) -...
 
Devops on serverless
Devops on serverlessDevops on serverless
Devops on serverless
 
Application Lifecycle Management in a Serverless World | AWS Public Sector Su...
Application Lifecycle Management in a Serverless World | AWS Public Sector Su...Application Lifecycle Management in a Serverless World | AWS Public Sector Su...
Application Lifecycle Management in a Serverless World | AWS Public Sector Su...
 
Deep Dive on Serverless Application Development
Deep Dive on Serverless Application DevelopmentDeep Dive on Serverless Application Development
Deep Dive on Serverless Application Development
 
Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...
Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...
Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...
 
Serverless Functions Deep Dive
Serverless Functions Deep DiveServerless Functions Deep Dive
Serverless Functions Deep Dive
 
Serverless functions deep dive
Serverless functions deep diveServerless functions deep dive
Serverless functions deep dive
 
Deep Dive On Serverless App Development
Deep Dive On Serverless App DevelopmentDeep Dive On Serverless App Development
Deep Dive On Serverless App Development
 
Deep Dive on Serverless App Development
Deep Dive on Serverless App DevelopmentDeep Dive on Serverless App Development
Deep Dive on Serverless App Development
 
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
 
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS SummitBuilding serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
Amazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
Amazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
Amazon Web Services
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Amazon Web Services
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
Amazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
Amazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Amazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
Amazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Amazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Building CICD Pipelines for Serverless Applications

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Building CI/CD Pipelines for Serverless Applications Prakash Palanisamy, Solutions Architect | 11th Oct, 2018
  • 2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless application SERVICES (ANYTHING) Changes in data state Requests to endpoints Changes in resource state EVENT SOURCE FUNCTION Node.js Python Java C# GO PowerShell
  • 3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon S3 Amazon DynamoDB Amazon Kinesis AWS CloudFormation AWS CloudTrail Amazon CloudWatch Amazon Cognito Cron events DATA STORES ENDPOINTS DEVELOPMENT AND MANAGEMENT TOOLS EVENT/MESSAGE SERVICES Example event sources that trigger AWS Lambda … and a few more with more on the way! AWS CodeCommit AWS IoT AWS Step Functions Amazon Alexa Amazon SES Amazon SQS Amazon SNS Amazon API Gateway
  • 4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Understanding “CI & CD” Source Build Test Production Continuous integration Continuous delivery Continuous deployment
  • 5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CI/CD for serverless applications There are a number of different paradigms we need to take into account when doing CI&CD for serverless applications: • Lambda functions are a unit of deployment • We’ll typically have multiple Lambda functions per application • Each function will have an event trigger • Could be shared or unique to each function • A serverless application is typically a combination of AWS Lambda + other AWS services
  • 6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CI/CD for serverless applications We’ll want to deliver our serverless application via a traditional development pipeline: • Pipeline initiated after code is committed to a repository • Built, tested, and verified at the code level exactly once • Aim for single artifact per deploy • Integration tested at functional and end-to-end levels • Deployed to independent environments for each stage of this process • Allow for those independent environments to be deployed exactly the same way across infrastructure + application
  • 7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Development Workflow Checklist q Model your application and infrastructure resources q Configure multiple environments q Automate your delivery process q Collect metrics and logs
  • 8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. An example of services for building serverless applications: Best practice: Manage these AWS resources with “Infrastructure as Code” practices/tools! Amazon S3 Amazon DynamoDB AWS Step Functions Amazon SQS Amazon SNS Amazon API Gateway Amazon Kinesis
  • 9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Create templates of your infrastructure CloudFormation provisions AWS resources based on dependency needs Version control/replicate/update templates like code Integrates with development, CI/CD, management tools JSON and YAML supported AWS CloudFormation Create templates of your infrastructure CloudFormation provisions AWS resources based on dependency needs Version control/replicate/update templates like code Integrates with development, CI/CD, management tools JSON and YAML supported
  • 10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudFormation template AWSTemplateFormatVersion: '2010-09-09' Resources: GetHtmlFunctionGetHtmlPermissionProd: Type: AWS::Lambda::Permission Properties: Action: lambda:invokeFunction Principal: apigateway.amazonaws.com FunctionName: Ref: GetHtmlFunction SourceArn: Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/Prod/ANY/* ServerlessRestApiProdStage: Type: AWS::ApiGateway::Stage Properties: DeploymentId: Ref: ServerlessRestApiDeployment RestApiId: Ref: ServerlessRestApi StageName: Prod ListTable: Type: AWS::DynamoDB::Table Properties: ProvisionedThroughput: WriteCapacityUnits: 5 ReadCapacityUnits: 5 AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - KeyType: HASH AttributeName: id GetHtmlFunction: Type: AWS::Lambda::Function Properties: Handler: index.gethtml Code: S3Bucket: flourish-demo-bucket S3Key: todo_list.zip Role: Fn::GetAtt: - GetHtmlFunctionRole - Arn Runtime: nodejs4.3 GetHtmlFunctionRole: Type: AWS::IAM::Role Properties: ManagedPolicyArns: - arn:aws:iam::aws:policy/AmazonDynamoDBReadOnlyAccess - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Action: - sts:AssumeRole Effect: Allow Principal: Service: - lambda.amazonaws.com ServerlessRestApiDeployment: Type: AWS::ApiGateway::Deployment Properties: RestApiId: Ref: ServerlessRestApi Description: 'RestApi deployment id: 127e3fb91142ab1ddc5f5446adb094442581a90d' StageName: Stage GetHtmlFunctionGetHtmlPermissionTest: Type: AWS::Lambda::Permission Properties: Action: lambda:invokeFunction Principal: apigateway.amazonaws.com FunctionName: Ref: GetHtmlFunction SourceArn: Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/*/ANY/* ServerlessRestApi: Type: AWS::ApiGateway::RestApi Properties: Body: info: version: '1.0' title: Ref: AWS::StackName paths: "/{proxy+}": x-amazon-apigateway-any-method: x-amazon-apigateway-integration: httpMethod: ANY type: aws_proxy uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03- 31/functions/${GetHtmlFunction.Arn}/invocations responses: {} swagger: '2.0'
  • 11. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudFormation template AWSTemplateFormatVersion: '2010-09-09' Resources: GetHtmlFunctionGetHtmlPermissionProd: Type: AWS::Lambda::Permission Properties: Action: lambda:invokeFunction Principal: apigateway.amazonaws.com FunctionName: Ref: GetHtmlFunction SourceArn: Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/Prod/ANY/* ServerlessRestApiProdStage: Type: AWS::ApiGateway::Stage Properties: DeploymentId: Ref: ServerlessRestApiDeployment RestApiId: Ref: ServerlessRestApi StageName: Prod ListTable: Type: AWS::DynamoDB::Table Properties: ProvisionedThroughput: WriteCapacityUnits: 5 ReadCapacityUnits: 5 AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - KeyType: HASH AttributeName: id GetHtmlFunction: Type: AWS::Lambda::Function Properties: Handler: index.gethtml Code: S3Bucket: flourish-demo-bucket S3Key: todo_list.zip Role: Fn::GetAtt: - GetHtmlFunctionRole - Arn Runtime: nodejs4.3 GetHtmlFunctionRole: Type: AWS::IAM::Role Properties: ManagedPolicyArns: - arn:aws:iam::aws:policy/AmazonDynamoDBReadOnlyAccess - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Action: - sts:AssumeRole Effect: Allow Principal: Service: - lambda.amazonaws.com ServerlessRestApiDeployment: Type: AWS::ApiGateway::Deployment Properties: RestApiId: Ref: ServerlessRestApi Description: 'RestApi deployment id: 127e3fb91142ab1ddc5f5446adb094442581a90d' StageName: Stage GetHtmlFunctionGetHtmlPermissionTest: Type: AWS::Lambda::Permission Properties: Action: lambda:invokeFunction Principal: apigateway.amazonaws.com FunctionName: Ref: GetHtmlFunction SourceArn: Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/*/ANY/* ServerlessRestApi: Type: AWS::ApiGateway::RestApi Properties: Body: info: version: '1.0' title: Ref: AWS::StackName paths: "/{proxy+}": x-amazon-apigateway-any-method: x-amazon-apigateway-integration: httpMethod: ANY type: aws_proxy uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03- 31/functions/${GetHtmlFunction.Arn}/invocations responses: {} swagger: '2.0'
  • 12. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 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) https://github.com/awslabs/serverless-application-model
  • 13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM template AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetHtmlFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip Handler: index.gethtml Runtime: nodejs4.3 Policies: AmazonDynamoDBReadOnlyAccess Events: GetHtml: Type: Api Properties: Path: /{proxy+} Method: ANY ListTable: Type: AWS::Serverless::SimpleTable Tells CloudFormation that this is a SAM template it needs to “transform” Creates a Lambda function with the referenced managed IAM policy, runtime, code at the referenced zip location, and handler as defined. Also creates an API Gateway and takes care of all mapping/permissions necessary Creates a DynamoDB table with 5 Read & Write units Tells CloudFormation that this is a SAM template it needs to “transform” Creates a Lambda function with the referenced managed IAM policy, runtime, code at the referenced zip location, and handler as defined. Also creates an API Gateway and takes care of all mapping/permissions necessary
  • 14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM template From: https://github.com/awslabs/aws-serverless-samfarm/blob/master/api/saml.yaml <-THIS BECOMES THIS-> From: https://github.com/awslabs/aws-serverless-samfarm/blob/master/api/saml.yaml
  • 15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM template properties AWS::Serverless::Function AWS::Serverless::Api AWS::Serverless::SimpleTable Starting SAM Version 2016-10-31
  • 16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM template properties AWS::Serverless::Function AWS::Serverless::Api AWS::Serverless::SimpleTable Starting SAM Version 2016-10-31 Handler: index.js Runtime: nodejs4.3 CodeUri: 's3://my-code-bucket/my- function.zip' Description: Creates thumbnails of uploaded images MemorySize: 1024 Timeout: 15 Policies: AmazonS3FullAccess Environment: Variables: TABLE_NAME: my-table Events: PhotoUpload: Type: S3 Properties: Bucket: my-photo-bucket
  • 17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM template properties AWS::Serverless::Function AWS::Serverless::Api AWS::Serverless::SimpleTable From SAM Version 2016-10-31 StageName: prod DefinitionUri: swagger.yml CacheClusterEnabled: true CacheClusterSize: 28.4 Variables: VarName: VarValue
  • 18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM template properties AWS::Serverless::Function AWS::Serverless::Api AWS::Serverless::SimpleTable From SAM Version 2016-10-31 PrimaryKey: Name: id Type: String ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5
  • 19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM template capabilities • Can mix in other non-SAM CloudFormation resources in the same template • Examples: Amazon S3, Amazon Kinesis, AWS Step Functions • Supports use of parameters, mappings, outputs, etc. • Supports intrinsic functions • Can use ImportValue (exceptions for RestApiId, Policies, StageName attributes) • YAML or JSON
  • 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 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
  • 21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Development Workflow Checklist ü Model your application and infrastructure resources q Configure multiple environments q Automate your delivery process q Collect metrics and logs
  • 22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Configure multiple environments Good developers know they need different environments for building, testing, and running their applications! Why? • Avoid overlapping usage of resources • Safely test new code without impacting your customers • Safely test infrastructure changes How? • AWS account strategies • Using infrastructure as code tools • Using variables unique to each environment • Automating application delivery/testing
  • 23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Configure multiple environments Same account, different stacks: + Easier management of resources + Easier visibility via management/monitoring tools - Can be harder to create permission/access separation Better for smaller teams/individuals Two popular AWS account strategies: Multiple accounts: + Assured separation of permissions and access + Resource limits per account to control usage - Overhead of managing multiple accounts and controls between them Better for larger teams/companies Check out AWS Organizations
  • 24. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Environment Variables • Key-value pairs that you can dynamically pass to your function • Available via standard environment variable APIs such as process.env for Node.js or os.environ for Python • Can optionally be encrypted via KMS • Allows you to specify in IAM what roles have access to the keys to decrypt the information • Useful for creating environments per stage (such as dev, testing, production)
  • 25. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. API Gateway Stage Variables • Stage variables act like environment variables • Use stage variables to store configuration values • Stage variables are available in the $context object • Values are accessible from most fields in API Gateway • Lambda function ARN • HTTP endpoint • Custom authorizer function name • Parameter mappings
  • 26. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Template File Defining Stack Source Control Dev Test Prod Use the version control system of your choice to store and track changes to this template Build out multiple environments, such as for development, test, production and even DR using the same template, even across accounts Many environments from one template
  • 27. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda and API Gateway Variables + SAM Parameters: MyEnvironment: Type: String Default: testing AllowedValues: - testing - staging - prod Description: Environment of this stack of resources SpecialFeature1: Type: String Default: false AllowedValues: - true - false Description: Enable new SpecialFeature1 … #Lambda MyFunction: Type: 'AWS::Serverless::Function' Properties: … Environment: Variables: ENVIRONMENT: !Ref: MyEnvironment Spec_Feature1: !Ref: SpecialFeature1 … #API Gateway MyApiGatewayApi: Type: AWS::Serverless::Api Properties: … Variables: ENVIRONMENT: !Ref: MyEnvironment SPEC_Feature1: !Ref: SpecialFeature1 …
  • 28. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Development Workflow Checklist ü Model your application and infrastructure resources ü Configure multiple environments q Automate your delivery process q Collect metrics and logs
  • 29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Building a deployment package Node.js & Python • .zip file consisting of your code and any dependencies • Use npm/pip to install libraries • All dependencies must be at root level Java • Either .zip file with all code/dependencies, or standalone .jar • Use Maven / Eclipse IDE plugins • Compiled class & resource files at root level, required jars in /lib directory C# (.NET Core) • Either .zip file with all code/dependencies, or a standalone .dll • Use NuGet / VisualStudio plugins • All assemblies (.dll) at root level
  • 30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Building a deployment package GO • .zip file consisting of your code and any dependencies using build-lambda-zip • Use go get to download the libraries • All dependencies must be at root level PowerShell • .zip file with all code/dependencies. • Use NuGet and PowerShell Cmd-let New-AWSPowerShellLambdaPa ckage • All dependencies at root level
  • 31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Fully managed build service that compiles source code, runs tests, and produces software packages Scales continuously and processes multiple builds concurrently You can provide custom build environments suited to your needs via Docker images Only pay by the minute for the compute resources you use Launched with AWS CodePipeline and Jenkins integration Can be used as a “Test” action in CodePipeline AWS CodeBuild
  • 32. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Variables to be used by phases of build • Examples for what you can do in the phases of a build: • You can install packages or run commands to prepare your environment in “install”. • Run syntax checking, commands in “pre_build”. • Execute your build tool/command in “build” • Test your app further or ship a container image to a repository in post_build • Create and store an artifact in S3 buildspec.yml Exampleversion: 0.1 environment_variables: plaintext: "INPUT_FILE": "saml.yaml” "S3_BUCKET": "" phases: install: commands: - npm install pre_build: commands: - eslint *.js build: commands: - npm test post_build: commands: - aws cloudformation package --template $INPUT_FILE --s3- bucket $S3_BUCKET --output-template post-saml.yaml artifacts: type: zip files: - post-saml.yaml - beta.json
  • 33. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Establish our testing/validation model We want to make sure our code: • Is without syntax issues • Meets company standards for format • Compiles • Is sufficiently tested at the code level via unit tests We want to make sure our serverless service: • Functions as it is supposed to in relation to other components • Has appropriate mechanisms to handle failures up or down stream We want to make sure our entire application/infrastructure: • Functions end to end • Follows security best practices • Handles scaling demands
  • 34. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Automates code deployments to any instance Handles the complexity of updating your applications Avoid downtime during application deployment Rollback automatically if failure detected Deploy to Amazon EC2 or on-premises servers, in any language and on any operating system Integrates with third-party tools and AWS AWS CodeDeploy
  • 35. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM Globals + Safe Deployments Globals: Function: Runtime: nodejs4.3 AutoPublishAlias: !Ref ENVIRONMENT MyLambdaFunction: Type: AWS::Serverless::Function Properties: Handler: index.handler DeploymentPreference: Type: Linear10PercentEvery10Minutes Alarms: # A list of alarms that you want to monitor - !Ref AliasErrorMetricGreaterThanZeroAlarm - !Ref LatestVersionErrorMetricGreaterThanZeroAlarm Hooks: # Validation Lambda functions that are run before & after traffic shifting PreTraffic: !Ref PreTrafficLambdaFunction PostTraffic: !Ref PostTrafficLambdaFunction
  • 36. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Alias Traffic Shifting & AWS SAM In SAM: Note: You can specify a maximum of 10 alarms Alarms: # A list of alarms that you want to monitor - !Ref AliasErrorMetricGreaterThanZeroAlarm - !Ref LatestVersionErrorMetricGreaterThanZeroAlarm Hooks: # Validation Lambda functions that are run before & after traffic shifting PreTraffic: !Ref PreTrafficLambdaFunction PostTraffic: !Ref PostTrafficLambdaFunction
  • 37. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway Canary Support Use canary release deployments to gradually roll out new APIs in Amazon API Gateway: • configure percent of traffic to go to a new stage deployment • can test stage settings and variables • API gateway will create additional Amazon CloudWatch Logs group and CloudWatch metrics for the requests handled by the canary deployment API • To rollback: delete the deployment or set percent of traffic to 0
  • 38. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Continuous delivery service for fast and reliable application updates Model and visualize your software release process Builds, tests, and deploys your code every time there is a code change Integrates with third-party tools and AWS AWS CodePipeline
  • 39. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Delivery via AWS CodePipeline Pipeline flow: 1. Commit your code to a source code repository 2. Package/test in AWS CodeBuild 3. Use CloudFormation actions in AWS CodePipeline to create or update stacks via SAM templates Optional: Make use of ChangeSets 4. Make use of specific stage/environment parameter files to pass in AWS Lambda variables 5. Test our application between stages/environments Optional: Make use of manual approvals
  • 40. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CodePipeline + CloudFormation Parameters Via referenced parameter file: Via Parameter Overrides:
  • 41. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CodePipeline + CloudFormation Parameters Via referenced parameter file: Pros: • Allows developers to update and provide parameters via file in the code repository • Easier to change and iterate via deployment Cons: • Potentially harder to control security or confidential information passed in
  • 42. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CodePipeline + CloudFormation Parameters Via Parameter Overrides:Pros: • Tighter control over parameters passed in • Can restrict access to information based on visibility to CodePipeline and CloudFormation Cons: • Modification requires a change to the pipeline and a re-execution • Harder to track the changes to these values unless you are tracking them via CloudFormation to manage the pipeline(as an example)
  • 43. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Source Source CodeCommit MyApplication An example minimal pipeline: Build test-build-source CodeBuild Deploy Testing create-changeset AWS CloudFormation execute-changeset AWS CloudFormation Run-stubs AWS Lambda Deploy Staging create-changeset AWS CloudFormation execute-changeset AWS CloudFormation Run-API-test Runscope QA-Sign-off Manual Approval Review Deploy Prod create-changeset AWS CloudFormation execute-changeset AWS CloudFormation Post-Deploy-Slack AWS Lambda This pipeline: • Five stages • Builds code artifact • Three deployed to “environments” • Uses CloudFormation to deploy artifact and other AWS resources • Has Lambda custom actions for running my own testing functions • Integrates with a third-party tool/service • Has a manual approval before deploying to production
  • 44. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Code Services Source Build Test Production Third-Party Tooling Software Release Steps: AWS CodeCommit AWS CodeBuild AWS CodeDeploy AWS CodePipeline
  • 45. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Development Workflow Checklist ü Model your application and infrastructure resources ü Configure multiple environments ü Automate your delivery process q Collect metrics and logs
  • 46. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Metrics and logs • Default (free) metrics: • Invocations • Duration • Throttles • Errors • Create custom metrics for health and status tracking CloudWatch Metrics CloudWatch Logs • Every invocation generates START, END and REPORT entries to CW Logs • Emit your own log entries • Use third-party tools for aggregation and visualization
  • 47. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray + AWS Lambda • Collects data about requests that your application serves • Provides diagnostic tools • Visibility into the AWS Lambda service • Breakdown of your function’s performance
  • 48. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Service map Identify where your errors or latency problems are coming from
  • 49. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Trace view Zoom in to determine the root cause
  • 50. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. DEMO!
  • 51. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. aws.amazon.com/serverless
  • 52. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. aws.amazon.com/serverless/developer-tools
  • 53. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Additional resources Serverless Application Model (SAM) - https://github.com/awslabs/serverless- application-model Learn more: AWS Lambda: https://aws.amazon.com/lambda Amazon API Gateway: https://aws.amazon.com/api-gateway Products that helped us today: AWS CloudFormation: https://aws.amazon.com/cloudformation AWS CodePipeline: https://aws.amazon.com/codepipeline AWS CodeDeploy: https://aws.amazon.com/codedeploy/ AWS CodeBuild: https://aws.amazon.com/codebuild
  • 54. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you!!!