SlideShare a Scribd company logo
1 of 90
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
O S L O
2019.04.03
CI/CD for Modern Applications
Danilo Poccia
Principal Evangelist, Serverless
@danilop
M A D 1
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Development transformation at Amazon: 2001–2002
monolithic application
+ teams
2001
Lesson learned: decompose for agility
2002
microservices
+ 2 pizza teams
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Full ownership
Full accountability
“DevOps”
Focused innovation
Two-pizza teams
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Monolith development lifecycle
monitorreleasetestbuild
developers
delivery pipelines
services
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Microservice development lifecycle
???
developers
delivery pipelines
services
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Microservice development lifecycle
developers services
monitorreleasetestbuild
delivery pipelines
monitorreleasetestbuild
monitorreleasetestbuild
monitorreleasetestbuild
monitorreleasetestbuild
monitorreleasetestbuild
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ListenIterate
Experiment
Innovation
Flywheel
Experiments power the engine of rapid innovation
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Approaches to modern application development
• Simplify environment management
• Reduce the impact of code changes
• Automate operations
• Accelerate the delivery of new, high-quality services
• Gain insight across resources and applications
• Protect customers and the business
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Approaches to modern application development
• Simplify environment management with serverless technologies
• Reduce the impact of code changes with microservice architectures
• Automate operations by modeling applications & infrastructure as code
• Accelerate the delivery of new, high-quality services with CI/CD
• Gain insight across resources and applications by enabling observability
• Protect customers and the business with end-to-end security & compliance
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Approaches to modern application development
• Simplify environment management with serverless technologies
• Reduce the impact of code changes with microservice architectures
• Automate operations by modeling applications & infrastructure as code
• Accelerate the delivery of new, high-quality services with CI/CD
• Gain insight across resources and applications by enabling observability
• Protect customers and the business with end-to-end security & compliance
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
What is serverless?
No infrastructure provisioning,
no management
Automatic scaling
Pay for value Highly available and secure
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Approaches to modern application development
Serverless containers
Long-running
Abstracts the OS
Fully managed orchestration
Fully managed cluster scaling
Serverless functions
Event-driven
Many language runtimes
Data source integrations
No server management
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Comparison of operational responsibility
AWS Lambda
Serverless functions
AWS Fargate
Serverless containers
ECS/EKS
Container-management as a service
EC2
Infrastructure-as-a-Service
More opinionated
Less opinionated
AWS manages Customer manages
• Data source integrations
• Physical hardware, software, networking,
and facilities
• Provisioning
• Application code
• Container orchestration, provisioning
• Cluster scaling
• Physical hardware, host OS/kernel,
networking, and facilities
• Application code
• Data source integrations
• Security config and updates, network config,
management tasks
• Container orchestration control plane
• Physical hardware software,
networking, and facilities
• Application code
• Data source integrations
• Work clusters
• Security config and updates, network config,
firewall, management tasks
• Physical hardware software,
networking, and facilities
• Application code
• Data source integrations
• Scaling
• Security config and updates, network config,
management tasks
• Provisioning, managing scaling and
patching of servers
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Approaches to modern application development
• Simplify environment management with serverless technologies
• Reduce the impact of code changes with microservice architectures
• Automate operations by modeling applications & infrastructure as code
• Accelerate the delivery of new, high-quality services with CI/CD
• Gain insight across resources and applications by enabling observability
• Protect customers and the business with end-to-end security & compliance
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Release process stages
Source Build Test Production
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Release process stages
Source Build Test Production
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Release process stages
Source Build Test Production
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Infrastructure
as code
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Infrastructure as code
Declarative
I tell you
what I need
I tell you
what to do
Imperative
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Infrastructure as code goals
1. Make infrastructure changes repeatable and predictable
2. Release infrastructure changes using the same tools as code changes
3. Replicate production environment in a staging environment to enable
continuous testing
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Release infrastructure-as-code
“Master”
branch
Prepare
template
Create & execute
change set
Create & execute
change set
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Model function environments with AWS
Serverless Application Model (SAM)
• Open source framework for building serverless
applications on AWS
• Shorthand syntax to express functions, APIs,
databases, and event source mappings
• Transforms and expands SAM syntax into AWS
CloudFormation syntax on deployment
• Supports all AWS CloudFormation resource types
https://aws.amazon.com/serverless/sam
O
pen
Source
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SAM template
AWSTemplateFormatVersion: '2010-09-09’
Transform: AWS::Serverless-2016-10-31
Resources:
GetFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.get
Runtime: nodejs8.10
CodeUri: src/
Policies:
- DynamoDBReadPolicy:
TableName: !Ref MyTable
Events:
GetResource:
Type: Api
Properties:
Path: /resource/{resourceId}
Method: get
MyTable:
Type: AWS::Serverless::SimpleTable
Just 20 lines to create:
• Lambda function
• IAM role
• API Gateway
• DynamoDB table
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Use SAM CLI to package and deploy SAM templates
sam init --name my-function --runtime python
cd my-function/
sam validate
sam local generate-event/invoke/start-api/start-lambda
sam build # Depending on the runtime
sam package --s3-bucket my-packages-bucket 
--output-template-file packaged.yaml
sam deploy --template-file packaged.yaml 
--stack-name my-stack-prod
sam logs -n MyFunction --stack-name my-stack-prod -t
sam publish # To the Serverless Application Repository
O
pen
Source
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
TweetSource:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:...
SemanticVersion: 2.0.0
Parameters:
TweetProcessorFunctionName: !Ref MyFunction
SearchText: '#serverless -filter:nativeretweets'
Nested apps to simplify solving recurring problems
Standard
Component
Custom
Business
Logic
Polling schedule
(CloudWatch
Events rule)
trigger
TwitterProcessor
SearchCheckpoint
TwitterSearchPoller
Twitter
Search API
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Model container environments with AWS
Cloud Development Kit (CDK)
Developer
Preview
• Open source framework to define cloud
infrastructure in JavaScript, TypeScript, Java, C#,
Python, …
• Provides library of higher-level resource types
(“construct” classes) that have AWS best practices
built in by default, packaged as npm modules
• Provisions resources with CloudFormation
• Supports all CloudFormation resource types
AWS
CDK
https://awslabs.github.io/aws-cdk
O
pen
Source
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
import cdk = require('@aws-cdk/cdk');
import ec2 = require('@aws-cdk/aws-ec2');
import ecs = require('@aws-cdk/aws-ecs');
class BonjourFargate extends cdk.Stack {
constructor(parent: cdk.App, name: string, props?: cdk.StackProps) {
super(parent, name, props);
const vpc = new ec2.VpcNetwork(this, 'MyVpc', { maxAZs: 2 });
const cluster = new ecs.Cluster(this, 'Cluster', { vpc });
new ecs.LoadBalancedFargateService(
this, "FargateService", {
cluster,
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
});
}
}
const app = new cdk.App();
new BonjourFargate(app, 'Bonjour');
app.run();
CDK template
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
import cdk = require('@aws-cdk/cdk');
import ec2 = require('@aws-cdk/aws-ec2');
import ecs = require('@aws-cdk/aws-ecs');
class BonjourFargate extends cdk.Stack {
constructor(parent: cdk.App, name: string, props?: cdk.StackProps) {
super(parent, name, props);
const vpc = new ec2.VpcNetwork(this, 'MyVpc', { maxAZs: 2 });
const cluster = new ecs.Cluster(this, 'Cluster', { vpc });
new ecs.LoadBalancedFargateService(
this, "FargateService", {
cluster,
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
});
}
}
const app = new cdk.App();
new BonjourFargate(app, 'Bonjour');
app.run();
CDK template
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CDK template
import cdk = require('@aws-cdk/cdk');
import ec2 = require('@aws-cdk/aws-ec2');
import ecs = require('@aws-cdk/aws-ecs');
class BonjourFargate extends cdk.Stack {
constructor(parent: cdk.App, name: string, props?: cdk.StackProps) {
super(parent, name, props);
const vpc = new ec2.VpcNetwork(this, 'MyVpc', { maxAZs: 2 });
const cluster = new ecs.Cluster(this, 'Cluster', { vpc });
new ecs.LoadBalancedFargateService(
this, "FargateService", {
cluster,
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
});
}
}
const app = new cdk.App();
new BonjourFargate(app, 'Bonjour');
app.run();
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Model pipelines with AWS CDK
• Minimize copy-and-paste by using object-oriented language
• Define microservice pipeline “shape” in one class, then re-use it across
many pipelines
• CDK includes many high-level constructs for modeling a CodePipeline
pipeline, including automatically configuring IAM role policies
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CDK pipelines: Construct
export class MyMicroservicePipeline extends cdk.Construct {
constructor(parent: cdk.Construct, name: string, props:
MyMicroservicePipelineProps) {
super(parent, name);
const pipeline = new codepipeline.Pipeline(this, 'Pipeline', {
pipelineName: props.serviceName,
});
const githubAccessToken = new cdk.SecretParameter(this, 'GitHubToken’,
{ ssmParameter: 'GitHubToken' });
new codepipeline.GitHubSourceAction(this, 'GitHubSource', {
stage: pipeline.addStage('Source’),
owner: 'myorg’,
repo: props.serviceName,
oauthToken: githubAccessToken.value
});
…
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
import cdk = require('@aws-cdk/cdk');
import { MyMicroservicePipeline } from './pipeline';
class MyMicroservicePipelinesStack extends cdk.Stack {
constructor(parent: cdk.App, name: string, props?: cdk.StackProps) {
super(parent, name, props);
new MyMicroservicePipeline(this, 'Pipeline1', { 'serviceName': 'Microservice1' });
new MyMicroservicePipeline(this, 'Pipeline2', { 'serviceName': 'Microservice2' });
new MyMicroservicePipeline(this, 'Pipeline3', { 'serviceName': 'Microservice3' });
new MyMicroservicePipeline(this, 'Pipeline4', { 'serviceName': 'Microservice4' });
}
}
const app = new cdk.App();
new MyMicroservicePipelinesStack(app, 'MyMicroservicePipelines');
app.run();
CDK pipelines: Stack
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Use CDK CLI to synthesize and deploy CDK templates
npm install -g aws-cdk
cdk init app --language typescript
cdk synth
cdk deploy
cdk diff
cdk destroy
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Infrastructure
as code
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Continuous
integration
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous integration goals
Source Build Test Production
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous integration goals
1. Automatically kick off a new release when new code is checked in
2. Build and test code in a consistent, repeatable environment
3. Continually have an artifact ready for deployment
4. Continually close feedback loop when build fails
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodePipeline
• 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
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodePipeline: Supported sources
Pick branch
AWS CodeCommit
GitHub
Pick object or folder
Amazon S3
Pick Docker tag
Amazon ECR
Automatically kick off release and pull latest source code
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodePipeline: ECR source action
Source code:
“master” branch
ECR repository:
“release” tag
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodePipeline: Supported triggers
Automatically kick off release
Amazon CloudWatch Events
• Scheduled (nightly release)
• AWS Health events (Fargate
platform retirement)
Available in CloudWatch Events
console, API, SDK, CLI, and AWS
CloudFormation
Webhooks
• DockerHub
• Quay
• Artifactory
Available in CodePipeline API,
SDK, CLI, and CloudFormation
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeBuild
• Fully managed build service that compiles source
code, runs tests, and produces software packages
• Scales continuously and processes multiple builds
concurrently
• No build servers to manage
• Pay by the minute, only for the compute
resources you use
• Monitor builds through CloudWatch Events
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeBuild
• Each build runs in a new Docker container for a
consistent, immutable environment
• Docker and AWS CLI are installed in every official
CodeBuild image
• Provide custom build environments suited to
your needs through the use of Docker images
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeBuild: Lambda buildspec
version: 0.2
phases:
build:
commands:
- npm ci
- npm test
- >
aws cloudformation package
--template-file template.yaml
--output-template packaged.yaml
--s3-bucket $BUCKET
artifacts:
type: zip
files:
- packaged.yaml
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeBuild: Lambda buildspec using SAM CLI
version: 0.2
phases:
install:
commands:
- pip install --upgrade awscli aws-sam-cli
build:
commands:
- sam build
- sam package --s3-bucket $BUCKET --output-template-file packaged.yaml
artifacts:
type: zip
files:
- packaged.yaml
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeBuild: Docker buildspec
version: 0.2
phases:
build:
commands:
- $(aws ecr get-login --no-include-email)
- docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $ECR_REPO:$IMAGE_TAG
- docker push $ECR_REPO:$IMAGE_TAG
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous integration goals
1. Automatically kick off a new release when new code is checked in
2. Build and test code in a consistent, repeatable environment
3. Continually have an artifact ready for deployment
4. Continually close feedback loop when build fails
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Continuous
integration
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Continuous
deployment
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous deployment goals
Source Build Test Production
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous deployment goals
1. Automatically deploy new changes to staging environments for testing
2. Deploy to production safely without impacting customers
3. Deliver to customers faster: Increase deployment frequency,
and reduce change lead time and change failure rate
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeDeploy
• Automates code deployments to any instance
and Lambda
• Handles the complexity of updating your
applications
• Avoid downtime during application deployment
• Roll back automatically if failure detected
• Deploy to Amazon EC2, containers, Lambda, or
on-premises servers
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy – Lambda deployments
Enable in your serverless application template
Resources:
GetFunction:
Type: AWS::Serverless::Function
Properties:
DeploymentPreference:
Type: Canary10Percent10Minutes
Alarms:
- !Ref ErrorsAlarm
- !Ref LatencyAlarm
Hooks:
PreTraffic: !Ref PreTrafficHookFunction
PostTraffic: !Ref PostTrafficHookFunction
Canary10Percent30Minutes
Canary10Percent5Minutes
Canary10Percent10Minutes
Canary10Percent15Minutes
Linear10PercentEvery10Minutes
Linear10PercentEvery1Minute
Linear10PercentEvery2Minutes
Linear10PercentEvery3Minutes
AllAtOnce
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy – Lambda canary deployment
API
Gateway
Lambda
function
weighted
alias “live”
v1 Lambda
function
code
100%
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy – Lambda canary deployment
API
Gateway
Lambda
function
weighted
alias “live”
v1 code100%
Run PreTraffic hook against v2 code before it receives traffic
v2 code0%
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy – Lambda canary deployment
API
Gateway
Lambda
function
weighted
alias “live”
v1 code90%
Wait for 10 minutes, roll back in case of alarm
v2 code10%
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy – Lambda canary deployment
API
Gateway
Lambda
function
weighted
alias “live”
v1 code0%
Run PostTraffic hook and complete deployment
v2 code100%
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
API Gateway canary stage
API
Gateway
Production
stage
v1 code
v2 code
99.5%
0.5%
Canary
stage
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployments
• Provisions “green” tasks, then flips traffic at the
load balancer
• Validation “hooks” enable testing at each stage of
the deployment
• Fast rollback to “blue” tasks in seconds if case of
hook failure or CloudWatch alarms
• Monitor deployment status and history via
console, API, Amazon SNS notifications, and
CloudWatch Events
• Use “CodeDeploy-ECS” deploy action in
CodePipeline or “aws ecs deploy” command in
Jenkins
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS appspec
version: 1.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
- TaskDefinition: "my_task_definition:8"
LoadBalancerInfos:
- ContainerName: "SampleApp"
ContainerPort: 80
Hooks:
- BeforeInstall: "LambdaFunctionToExecuteAnythingBeforeNewRevisionInstalltion"
- AfterInstall: "LambdaFunctionToExecuteAnythingAfterNewRevisionInstallation"
- AfterAllowTestTraffic: "LambdaFunctionToValidateAfterTestTrafficShift"
- BeforeAllowTraffic: "LambdaFunctionToValidateBeforeTrafficShift"
- AfterAllowTraffic: "LambdaFunctionToValidateAfterTrafficShift"
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployment
100%
Prod
traffic
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployment
Target
group 2
100%
Prod
traffic
Test traffic listener
(port 9000)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployment
Green tasks:
v2 code
100%
Prod
traffic
Provision green tasks
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployment
100%
Test
traffic
100%
Prod
traffic
Run hook against test endpoint before green tasks receive prod traffic
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployment
100%
Prod
traffic
Flip traffic to green tasks, rollback in case of alarm
0%
Prod
traffic
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployment
100%
Prod
traffic
Drain blue tasks
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
• Docker tags are resolved when each container starts, not just during
deployments
• Deploying “latest” or “prod” can result in untested code in production
after a scale-out event
• Use unique “immutable” tags for deployments
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
Build pushes new “latest” image
Image: sha256@22222... (“latest”)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
Service scales up, launching new tasks
Image: sha256@22222... (“latest”)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
Deploy using immutable tags
{
"name": "sample-app",
"image": "amazon/amazon-ecs-
sample@sha256:3e39d933b1d948c92309bb583b5a1f3d28f0119e1551ca1fe538ba414a41af48d"
}
{
"name": "sample-app",
"image": "amazon/amazon-ecs-sample:build-b2085490-359f-4eaf-8970-6d1e26c354f0"
}
SHA256 Digest
Build ID
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
Compute immutable tags during build
SHA256 Digest
export IMAGE_URI=`docker inspect --format='{{index .RepoDigests 0}}' my_image:$IMAGE_TAG`
Example Result:
amazon/amazon-ecs-sample@sha256:3e39d933b...
Build ID
export IMAGE_TAG=build-`echo $CODEBUILD_BUILD_ID | awk –F":" ‘{print $2}'`
Example Result:
build-b2085490-359f-4eaf-8970-6d1e26c354f0
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
Build pushes new image tagged with new build ID
Image: sha256@22222... (“build-22222”)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
Service scales up, launching new tasks
Image: sha256@22222... (“build-22222”)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
Image: “build-22222” tag
Deployment updates service’s task definition, replacing tasks
Image: sha256@22222... (“build-22222”)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous deployment goals
1. Automatically deploy new changes to staging environments for testing
2. Deploy to production safely without impacting customers
3. Deliver to customers faster: Increase deployment frequency,
and reduce change lead time and change failure rate
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Continuous
deployment
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Capital One – Credit Offers API serverless architecture
Affiliates
www.capitalone.com/
credit-cards/prequalify
AWS Cloud
Capital One
API Gateway
VPC
Lambda
Function
Traces Logs
Production Support
Command Center
COAT
Credit Offers API Team
Lambda
Function
S3 Bucket
TTL
Third-Party
API
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Capital One – Credit Offers API CI/CD pipeline
Continuous Improvement, Continuous Delivery!
GitHub LGTM Bot Jenkins AWS SAM
S3 Bucket
(Versioning)
Lambda
Function
DeploymentType:
dev: AllAtOnce
qa: AllAtOnce
qaw: AllAtOnce
prod: Canary10Percent10Minutes
prodw: Canary10Percent10Minutes
canary5xxGetProductsAlarm:
Type: AWS::CloudFormation::Alarm
Properties:
AlarmActions:
- !FindInMap:
- params
- AdminSNSTopic
- !Ref Environment
AlarmDescription: 500 error from product
listing Lambda.
ComparisonOperator:
GreatherThanOrEqualTothreshold
Period: 300
Statistic: Sum
Threshold: 1
EvaluationPeriod: 1
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Capital One – Benefits from taking the API serverless
Performance gains
From the time the request
is received by lambda to
the time to send the
response back
70%
Cost savings
By removing EC2, ELB and
RDS from our solution
90%
Increase in team velocity
Reduce investment in team’s time
on DevOps and dedicate back to
feature development!
30%
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Demo – Store & Reply
AWS Cloud
Region
https://github.com/danilop/store-and-reply
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Takeaways
1. Manage your infrastructure as code
2. Frequently build and integrate your code to get a first feedback
3. Continuously release in production using canary releases with
monitoring and automated rollbacks
4. Use canary releases to get both technical and business feedback
Thank you!
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Danilo Poccia
@danilop

More Related Content

What's hot

Building Serverless Applications That Align with Twelve-Factor Methods - AWS ...
Building Serverless Applications That Align with Twelve-Factor Methods - AWS ...Building Serverless Applications That Align with Twelve-Factor Methods - AWS ...
Building Serverless Applications That Align with Twelve-Factor Methods - AWS ...Amazon Web Services
 
AWS 如何協助客戶建立 DevOps 流程
AWS 如何協助客戶建立 DevOps 流程AWS 如何協助客戶建立 DevOps 流程
AWS 如何協助客戶建立 DevOps 流程Amazon Web Services
 
Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...
Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...
Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...Amazon Web Services
 
Java Developer on AWS 在AWS上開發Java應用
Java Developer on AWS 在AWS上開發Java應用Java Developer on AWS 在AWS上開發Java應用
Java Developer on AWS 在AWS上開發Java應用Amazon Web Services
 
Modern Applications Development on AWS
Modern Applications Development on AWSModern Applications Development on AWS
Modern Applications Development on AWSBoaz Ziniman
 
Modernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS Summit
Modernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS SummitModernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS Summit
Modernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS SummitAmazon Web Services
 
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...Amazon Web Services
 
2020-04-02 DevConf - How to migrate an existing application to serverless
2020-04-02 DevConf - How to migrate an existing application to serverless2020-04-02 DevConf - How to migrate an existing application to serverless
2020-04-02 DevConf - How to migrate an existing application to serverlessMarcia Villalba
 
Building for scale with AWS Media Services
Building for scale with AWS Media ServicesBuilding for scale with AWS Media Services
Building for scale with AWS Media ServicesAmazon Web Services
 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry BootcampAndy Piper
 
How do you deliver your applications to the cloud?
How do you deliver your applications to the cloud?How do you deliver your applications to the cloud?
How do you deliver your applications to the cloud?Michael Elder
 
Takeaways from API Security Breaches Webinar
Takeaways from API Security Breaches WebinarTakeaways from API Security Breaches Webinar
Takeaways from API Security Breaches WebinarCA API Management
 
Building Private API’s for Security Automation at Monash University
Building Private API’s for Security Automation at Monash UniversityBuilding Private API’s for Security Automation at Monash University
Building Private API’s for Security Automation at Monash UniversityAmazon Web Services
 
API Monetization: Unlock the Value of Your Data
API Monetization: Unlock the Value of Your DataAPI Monetization: Unlock the Value of Your Data
API Monetization: Unlock the Value of Your DataCA API Management
 
Enabling the Multi-Device Universe
Enabling the Multi-Device UniverseEnabling the Multi-Device Universe
Enabling the Multi-Device UniverseCA API Management
 

What's hot (20)

Containers on AWS
Containers on AWSContainers on AWS
Containers on AWS
 
Building Serverless Applications That Align with Twelve-Factor Methods - AWS ...
Building Serverless Applications That Align with Twelve-Factor Methods - AWS ...Building Serverless Applications That Align with Twelve-Factor Methods - AWS ...
Building Serverless Applications That Align with Twelve-Factor Methods - AWS ...
 
AWS 如何協助客戶建立 DevOps 流程
AWS 如何協助客戶建立 DevOps 流程AWS 如何協助客戶建立 DevOps 流程
AWS 如何協助客戶建立 DevOps 流程
 
Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...
Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...
Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...
 
Java Developer on AWS 在AWS上開發Java應用
Java Developer on AWS 在AWS上開發Java應用Java Developer on AWS 在AWS上開發Java應用
Java Developer on AWS 在AWS上開發Java應用
 
Modern Applications Development on AWS
Modern Applications Development on AWSModern Applications Development on AWS
Modern Applications Development on AWS
 
Modernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS Summit
Modernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS SummitModernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS Summit
Modernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS Summit
 
Serverless - State of the Union
Serverless - State of the UnionServerless - State of the Union
Serverless - State of the Union
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
CI/CD Pipeline Security: Advanced Continuous Delivery Best Practices: Securit...
 
2020-04-02 DevConf - How to migrate an existing application to serverless
2020-04-02 DevConf - How to migrate an existing application to serverless2020-04-02 DevConf - How to migrate an existing application to serverless
2020-04-02 DevConf - How to migrate an existing application to serverless
 
Building for scale with AWS Media Services
Building for scale with AWS Media ServicesBuilding for scale with AWS Media Services
Building for scale with AWS Media Services
 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
 
What is Serverless Computing?
What is Serverless Computing?What is Serverless Computing?
What is Serverless Computing?
 
Aws and Alfresco Solutions
Aws and Alfresco SolutionsAws and Alfresco Solutions
Aws and Alfresco Solutions
 
How do you deliver your applications to the cloud?
How do you deliver your applications to the cloud?How do you deliver your applications to the cloud?
How do you deliver your applications to the cloud?
 
Takeaways from API Security Breaches Webinar
Takeaways from API Security Breaches WebinarTakeaways from API Security Breaches Webinar
Takeaways from API Security Breaches Webinar
 
Building Private API’s for Security Automation at Monash University
Building Private API’s for Security Automation at Monash UniversityBuilding Private API’s for Security Automation at Monash University
Building Private API’s for Security Automation at Monash University
 
API Monetization: Unlock the Value of Your Data
API Monetization: Unlock the Value of Your DataAPI Monetization: Unlock the Value of Your Data
API Monetization: Unlock the Value of Your Data
 
Enabling the Multi-Device Universe
Enabling the Multi-Device UniverseEnabling the Multi-Device Universe
Enabling the Multi-Device Universe
 

Similar to AWS Modern App Dev Approaches

AWS DevDay Cologne - CI/CD for modern applications
AWS DevDay Cologne - CI/CD for modern applicationsAWS DevDay Cologne - CI/CD for modern applications
AWS DevDay Cologne - CI/CD for modern applicationsCobus Bernard
 
DevOps - Moving to DevOps the Amazon Way
DevOps - Moving to DevOps the Amazon WayDevOps - Moving to DevOps the Amazon Way
DevOps - Moving to DevOps the Amazon WayAmazon Web Services
 
CICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdfCICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdfAmazon Web Services
 
CI/CD best practices for building modern applications - MAD302 - Atlanta AWS ...
CI/CD best practices for building modern applications - MAD302 - Atlanta AWS ...CI/CD best practices for building modern applications - MAD302 - Atlanta AWS ...
CI/CD best practices for building modern applications - MAD302 - Atlanta AWS ...Amazon Web Services
 
CI/CD best practices for building modern applications - MAD304 - Chicago AWS ...
CI/CD best practices for building modern applications - MAD304 - Chicago AWS ...CI/CD best practices for building modern applications - MAD304 - Chicago AWS ...
CI/CD best practices for building modern applications - MAD304 - Chicago AWS ...Amazon Web Services
 
CI/CD best practices for building modern applications - MAD301 - Santa Clara ...
CI/CD best practices for building modern applications - MAD301 - Santa Clara ...CI/CD best practices for building modern applications - MAD301 - Santa Clara ...
CI/CD best practices for building modern applications - MAD301 - Santa Clara ...Amazon Web Services
 
CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...
CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...
CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...Amazon Web Services
 
CI/CD best practices for building modern applications - MAD310 - New York AWS...
CI/CD best practices for building modern applications - MAD310 - New York AWS...CI/CD best practices for building modern applications - MAD310 - New York AWS...
CI/CD best practices for building modern applications - MAD310 - New York AWS...Amazon Web Services
 
DevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWSDevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWSatSistemas
 
Continuous Integration and Continuous Delivery Best Practices for Building Mo...
Continuous Integration and Continuous Delivery Best Practices for Building Mo...Continuous Integration and Continuous Delivery Best Practices for Building Mo...
Continuous Integration and Continuous Delivery Best Practices for Building Mo...Amazon Web Services
 
Progetta, crea e gestisci Modern Application per web e mobile su AWS
Progetta, crea e gestisci Modern Application per web e mobile su AWSProgetta, crea e gestisci Modern Application per web e mobile su AWS
Progetta, crea e gestisci Modern Application per web e mobile su AWSAmazon Web Services
 
Introduction to Serverless Computing - OOP Munich
 Introduction to Serverless Computing - OOP Munich Introduction to Serverless Computing - OOP Munich
Introduction to Serverless Computing - OOP MunichBoaz Ziniman
 
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019AWS Summits
 
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019Amazon Web Services
 
Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.
Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.
Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.Amazon Web Services LATAM
 
Websites go Serverless - AWS Summit Berlin
Websites go Serverless - AWS Summit BerlinWebsites go Serverless - AWS Summit Berlin
Websites go Serverless - AWS Summit BerlinBoaz Ziniman
 
Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...
Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...
Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...Amazon Web Services
 
CI/CD for Containers: A Way Forward for Your DevOps Pipeline
CI/CD for Containers: A Way Forward for Your DevOps PipelineCI/CD for Containers: A Way Forward for Your DevOps Pipeline
CI/CD for Containers: A Way Forward for Your DevOps PipelineAmazon Web Services
 

Similar to AWS Modern App Dev Approaches (20)

AWS DevDay Cologne - CI/CD for modern applications
AWS DevDay Cologne - CI/CD for modern applicationsAWS DevDay Cologne - CI/CD for modern applications
AWS DevDay Cologne - CI/CD for modern applications
 
CI/CD for Modern Applications
CI/CD for Modern ApplicationsCI/CD for Modern Applications
CI/CD for Modern Applications
 
DevOps - Moving to DevOps the Amazon Way
DevOps - Moving to DevOps the Amazon WayDevOps - Moving to DevOps the Amazon Way
DevOps - Moving to DevOps the Amazon Way
 
CICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdfCICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdf
 
CI/CD best practices for building modern applications - MAD302 - Atlanta AWS ...
CI/CD best practices for building modern applications - MAD302 - Atlanta AWS ...CI/CD best practices for building modern applications - MAD302 - Atlanta AWS ...
CI/CD best practices for building modern applications - MAD302 - Atlanta AWS ...
 
CI/CD best practices for building modern applications - MAD304 - Chicago AWS ...
CI/CD best practices for building modern applications - MAD304 - Chicago AWS ...CI/CD best practices for building modern applications - MAD304 - Chicago AWS ...
CI/CD best practices for building modern applications - MAD304 - Chicago AWS ...
 
CI/CD best practices for building modern applications - MAD301 - Santa Clara ...
CI/CD best practices for building modern applications - MAD301 - Santa Clara ...CI/CD best practices for building modern applications - MAD301 - Santa Clara ...
CI/CD best practices for building modern applications - MAD301 - Santa Clara ...
 
CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...
CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...
CI/CD Best Practices for Building Modern Applications - MAD302 - Anaheim AWS ...
 
CI/CD best practices for building modern applications - MAD310 - New York AWS...
CI/CD best practices for building modern applications - MAD310 - New York AWS...CI/CD best practices for building modern applications - MAD310 - New York AWS...
CI/CD best practices for building modern applications - MAD310 - New York AWS...
 
DevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWSDevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWS
 
Continuous Integration and Continuous Delivery Best Practices for Building Mo...
Continuous Integration and Continuous Delivery Best Practices for Building Mo...Continuous Integration and Continuous Delivery Best Practices for Building Mo...
Continuous Integration and Continuous Delivery Best Practices for Building Mo...
 
Progetta, crea e gestisci Modern Application per web e mobile su AWS
Progetta, crea e gestisci Modern Application per web e mobile su AWSProgetta, crea e gestisci Modern Application per web e mobile su AWS
Progetta, crea e gestisci Modern Application per web e mobile su AWS
 
Introduction to Serverless Computing - OOP Munich
 Introduction to Serverless Computing - OOP Munich Introduction to Serverless Computing - OOP Munich
Introduction to Serverless Computing - OOP Munich
 
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 
Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.
Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.
Inovação Rápida: O caso de negócio para desenvolvimento de aplicações modernas.
 
DevOps at Amazon
DevOps at AmazonDevOps at Amazon
DevOps at Amazon
 
Websites go Serverless - AWS Summit Berlin
Websites go Serverless - AWS Summit BerlinWebsites go Serverless - AWS Summit Berlin
Websites go Serverless - AWS Summit Berlin
 
Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...
Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...
Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...
 
CI/CD for Containers: A Way Forward for Your DevOps Pipeline
CI/CD for Containers: A Way Forward for Your DevOps PipelineCI/CD for Containers: A Way Forward for Your DevOps Pipeline
CI/CD for Containers: A Way Forward for Your DevOps Pipeline
 

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 FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon 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
 
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 WorkloadsAmazon 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 sfatareAmazon 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 NodeJSAmazon 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 webAmazon 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 sfatareAmazon 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 ServiceAmazon 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
 

AWS Modern App Dev Approaches

  • 1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. O S L O 2019.04.03 CI/CD for Modern Applications Danilo Poccia Principal Evangelist, Serverless @danilop M A D 1
  • 2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Development transformation at Amazon: 2001–2002 monolithic application + teams 2001 Lesson learned: decompose for agility 2002 microservices + 2 pizza teams
  • 3. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Full ownership Full accountability “DevOps” Focused innovation Two-pizza teams
  • 4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Monolith development lifecycle monitorreleasetestbuild developers delivery pipelines services
  • 5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Microservice development lifecycle ??? developers delivery pipelines services
  • 6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Microservice development lifecycle developers services monitorreleasetestbuild delivery pipelines monitorreleasetestbuild monitorreleasetestbuild monitorreleasetestbuild monitorreleasetestbuild monitorreleasetestbuild
  • 7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. ListenIterate Experiment Innovation Flywheel Experiments power the engine of rapid innovation
  • 8. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Approaches to modern application development • Simplify environment management • Reduce the impact of code changes • Automate operations • Accelerate the delivery of new, high-quality services • Gain insight across resources and applications • Protect customers and the business
  • 9. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Approaches to modern application development • Simplify environment management with serverless technologies • Reduce the impact of code changes with microservice architectures • Automate operations by modeling applications & infrastructure as code • Accelerate the delivery of new, high-quality services with CI/CD • Gain insight across resources and applications by enabling observability • Protect customers and the business with end-to-end security & compliance
  • 10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Approaches to modern application development • Simplify environment management with serverless technologies • Reduce the impact of code changes with microservice architectures • Automate operations by modeling applications & infrastructure as code • Accelerate the delivery of new, high-quality services with CI/CD • Gain insight across resources and applications by enabling observability • Protect customers and the business with end-to-end security & compliance
  • 11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. What is serverless? No infrastructure provisioning, no management Automatic scaling Pay for value Highly available and secure
  • 12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Approaches to modern application development Serverless containers Long-running Abstracts the OS Fully managed orchestration Fully managed cluster scaling Serverless functions Event-driven Many language runtimes Data source integrations No server management
  • 13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Comparison of operational responsibility AWS Lambda Serverless functions AWS Fargate Serverless containers ECS/EKS Container-management as a service EC2 Infrastructure-as-a-Service More opinionated Less opinionated AWS manages Customer manages • Data source integrations • Physical hardware, software, networking, and facilities • Provisioning • Application code • Container orchestration, provisioning • Cluster scaling • Physical hardware, host OS/kernel, networking, and facilities • Application code • Data source integrations • Security config and updates, network config, management tasks • Container orchestration control plane • Physical hardware software, networking, and facilities • Application code • Data source integrations • Work clusters • Security config and updates, network config, firewall, management tasks • Physical hardware software, networking, and facilities • Application code • Data source integrations • Scaling • Security config and updates, network config, management tasks • Provisioning, managing scaling and patching of servers
  • 14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Approaches to modern application development • Simplify environment management with serverless technologies • Reduce the impact of code changes with microservice architectures • Automate operations by modeling applications & infrastructure as code • Accelerate the delivery of new, high-quality services with CI/CD • Gain insight across resources and applications by enabling observability • Protect customers and the business with end-to-end security & compliance
  • 15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Release process stages Source Build Test Production
  • 16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Release process stages Source Build Test Production
  • 17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Release process stages Source Build Test Production
  • 18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications
  • 19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Infrastructure as code
  • 20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Infrastructure as code Declarative I tell you what I need I tell you what to do Imperative
  • 21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Infrastructure as code goals 1. Make infrastructure changes repeatable and predictable 2. Release infrastructure changes using the same tools as code changes 3. Replicate production environment in a staging environment to enable continuous testing
  • 22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Release infrastructure-as-code “Master” branch Prepare template Create & execute change set Create & execute change set
  • 23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Model function environments with AWS Serverless Application Model (SAM) • Open source framework for building serverless applications on AWS • Shorthand syntax to express functions, APIs, databases, and event source mappings • Transforms and expands SAM syntax into AWS CloudFormation syntax on deployment • Supports all AWS CloudFormation resource types https://aws.amazon.com/serverless/sam O pen Source
  • 24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. SAM template AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetFunction: Type: AWS::Serverless::Function Properties: Handler: index.get Runtime: nodejs8.10 CodeUri: src/ Policies: - DynamoDBReadPolicy: TableName: !Ref MyTable Events: GetResource: Type: Api Properties: Path: /resource/{resourceId} Method: get MyTable: Type: AWS::Serverless::SimpleTable Just 20 lines to create: • Lambda function • IAM role • API Gateway • DynamoDB table
  • 25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Use SAM CLI to package and deploy SAM templates sam init --name my-function --runtime python cd my-function/ sam validate sam local generate-event/invoke/start-api/start-lambda sam build # Depending on the runtime sam package --s3-bucket my-packages-bucket --output-template-file packaged.yaml sam deploy --template-file packaged.yaml --stack-name my-stack-prod sam logs -n MyFunction --stack-name my-stack-prod -t sam publish # To the Serverless Application Repository O pen Source
  • 26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. TweetSource: Type: AWS::Serverless::Application Properties: Location: ApplicationId: arn:aws:serverlessrepo:... SemanticVersion: 2.0.0 Parameters: TweetProcessorFunctionName: !Ref MyFunction SearchText: '#serverless -filter:nativeretweets' Nested apps to simplify solving recurring problems Standard Component Custom Business Logic Polling schedule (CloudWatch Events rule) trigger TwitterProcessor SearchCheckpoint TwitterSearchPoller Twitter Search API
  • 27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Model container environments with AWS Cloud Development Kit (CDK) Developer Preview • Open source framework to define cloud infrastructure in JavaScript, TypeScript, Java, C#, Python, … • Provides library of higher-level resource types (“construct” classes) that have AWS best practices built in by default, packaged as npm modules • Provisions resources with CloudFormation • Supports all CloudFormation resource types AWS CDK https://awslabs.github.io/aws-cdk O pen Source
  • 28. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. import cdk = require('@aws-cdk/cdk'); import ec2 = require('@aws-cdk/aws-ec2'); import ecs = require('@aws-cdk/aws-ecs'); class BonjourFargate extends cdk.Stack { constructor(parent: cdk.App, name: string, props?: cdk.StackProps) { super(parent, name, props); const vpc = new ec2.VpcNetwork(this, 'MyVpc', { maxAZs: 2 }); const cluster = new ecs.Cluster(this, 'Cluster', { vpc }); new ecs.LoadBalancedFargateService( this, "FargateService", { cluster, image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), }); } } const app = new cdk.App(); new BonjourFargate(app, 'Bonjour'); app.run(); CDK template
  • 29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. import cdk = require('@aws-cdk/cdk'); import ec2 = require('@aws-cdk/aws-ec2'); import ecs = require('@aws-cdk/aws-ecs'); class BonjourFargate extends cdk.Stack { constructor(parent: cdk.App, name: string, props?: cdk.StackProps) { super(parent, name, props); const vpc = new ec2.VpcNetwork(this, 'MyVpc', { maxAZs: 2 }); const cluster = new ecs.Cluster(this, 'Cluster', { vpc }); new ecs.LoadBalancedFargateService( this, "FargateService", { cluster, image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), }); } } const app = new cdk.App(); new BonjourFargate(app, 'Bonjour'); app.run(); CDK template
  • 30. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CDK template import cdk = require('@aws-cdk/cdk'); import ec2 = require('@aws-cdk/aws-ec2'); import ecs = require('@aws-cdk/aws-ecs'); class BonjourFargate extends cdk.Stack { constructor(parent: cdk.App, name: string, props?: cdk.StackProps) { super(parent, name, props); const vpc = new ec2.VpcNetwork(this, 'MyVpc', { maxAZs: 2 }); const cluster = new ecs.Cluster(this, 'Cluster', { vpc }); new ecs.LoadBalancedFargateService( this, "FargateService", { cluster, image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), }); } } const app = new cdk.App(); new BonjourFargate(app, 'Bonjour'); app.run();
  • 31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Model pipelines with AWS CDK • Minimize copy-and-paste by using object-oriented language • Define microservice pipeline “shape” in one class, then re-use it across many pipelines • CDK includes many high-level constructs for modeling a CodePipeline pipeline, including automatically configuring IAM role policies
  • 32. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CDK pipelines: Construct export class MyMicroservicePipeline extends cdk.Construct { constructor(parent: cdk.Construct, name: string, props: MyMicroservicePipelineProps) { super(parent, name); const pipeline = new codepipeline.Pipeline(this, 'Pipeline', { pipelineName: props.serviceName, }); const githubAccessToken = new cdk.SecretParameter(this, 'GitHubToken’, { ssmParameter: 'GitHubToken' }); new codepipeline.GitHubSourceAction(this, 'GitHubSource', { stage: pipeline.addStage('Source’), owner: 'myorg’, repo: props.serviceName, oauthToken: githubAccessToken.value }); …
  • 33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. import cdk = require('@aws-cdk/cdk'); import { MyMicroservicePipeline } from './pipeline'; class MyMicroservicePipelinesStack extends cdk.Stack { constructor(parent: cdk.App, name: string, props?: cdk.StackProps) { super(parent, name, props); new MyMicroservicePipeline(this, 'Pipeline1', { 'serviceName': 'Microservice1' }); new MyMicroservicePipeline(this, 'Pipeline2', { 'serviceName': 'Microservice2' }); new MyMicroservicePipeline(this, 'Pipeline3', { 'serviceName': 'Microservice3' }); new MyMicroservicePipeline(this, 'Pipeline4', { 'serviceName': 'Microservice4' }); } } const app = new cdk.App(); new MyMicroservicePipelinesStack(app, 'MyMicroservicePipelines'); app.run(); CDK pipelines: Stack
  • 34. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Use CDK CLI to synthesize and deploy CDK templates npm install -g aws-cdk cdk init app --language typescript cdk synth cdk deploy cdk diff cdk destroy
  • 35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Infrastructure as code
  • 36. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications
  • 37. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Continuous integration
  • 38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Continuous integration goals Source Build Test Production
  • 39. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Continuous integration goals 1. Automatically kick off a new release when new code is checked in 2. Build and test code in a consistent, repeatable environment 3. Continually have an artifact ready for deployment 4. Continually close feedback loop when build fails
  • 40. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodePipeline • 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
  • 41. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodePipeline: Supported sources Pick branch AWS CodeCommit GitHub Pick object or folder Amazon S3 Pick Docker tag Amazon ECR Automatically kick off release and pull latest source code
  • 42. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodePipeline: ECR source action Source code: “master” branch ECR repository: “release” tag
  • 43. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodePipeline: Supported triggers Automatically kick off release Amazon CloudWatch Events • Scheduled (nightly release) • AWS Health events (Fargate platform retirement) Available in CloudWatch Events console, API, SDK, CLI, and AWS CloudFormation Webhooks • DockerHub • Quay • Artifactory Available in CodePipeline API, SDK, CLI, and CloudFormation
  • 44. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodeBuild • Fully managed build service that compiles source code, runs tests, and produces software packages • Scales continuously and processes multiple builds concurrently • No build servers to manage • Pay by the minute, only for the compute resources you use • Monitor builds through CloudWatch Events
  • 45. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodeBuild • Each build runs in a new Docker container for a consistent, immutable environment • Docker and AWS CLI are installed in every official CodeBuild image • Provide custom build environments suited to your needs through the use of Docker images
  • 46. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodeBuild: Lambda buildspec version: 0.2 phases: build: commands: - npm ci - npm test - > aws cloudformation package --template-file template.yaml --output-template packaged.yaml --s3-bucket $BUCKET artifacts: type: zip files: - packaged.yaml
  • 47. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodeBuild: Lambda buildspec using SAM CLI version: 0.2 phases: install: commands: - pip install --upgrade awscli aws-sam-cli build: commands: - sam build - sam package --s3-bucket $BUCKET --output-template-file packaged.yaml artifacts: type: zip files: - packaged.yaml
  • 48. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodeBuild: Docker buildspec version: 0.2 phases: build: commands: - $(aws ecr get-login --no-include-email) - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG . - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $ECR_REPO:$IMAGE_TAG - docker push $ECR_REPO:$IMAGE_TAG
  • 49. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Continuous integration goals 1. Automatically kick off a new release when new code is checked in 2. Build and test code in a consistent, repeatable environment 3. Continually have an artifact ready for deployment 4. Continually close feedback loop when build fails
  • 50. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Continuous integration
  • 51. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications
  • 52. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Continuous deployment
  • 53. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Continuous deployment goals Source Build Test Production
  • 54. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Continuous deployment goals 1. Automatically deploy new changes to staging environments for testing 2. Deploy to production safely without impacting customers 3. Deliver to customers faster: Increase deployment frequency, and reduce change lead time and change failure rate
  • 55. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodeDeploy • Automates code deployments to any instance and Lambda • Handles the complexity of updating your applications • Avoid downtime during application deployment • Roll back automatically if failure detected • Deploy to Amazon EC2, containers, Lambda, or on-premises servers
  • 56. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy – Lambda deployments Enable in your serverless application template Resources: GetFunction: Type: AWS::Serverless::Function Properties: DeploymentPreference: Type: Canary10Percent10Minutes Alarms: - !Ref ErrorsAlarm - !Ref LatencyAlarm Hooks: PreTraffic: !Ref PreTrafficHookFunction PostTraffic: !Ref PostTrafficHookFunction Canary10Percent30Minutes Canary10Percent5Minutes Canary10Percent10Minutes Canary10Percent15Minutes Linear10PercentEvery10Minutes Linear10PercentEvery1Minute Linear10PercentEvery2Minutes Linear10PercentEvery3Minutes AllAtOnce
  • 57. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy – Lambda canary deployment API Gateway Lambda function weighted alias “live” v1 Lambda function code 100%
  • 58. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy – Lambda canary deployment API Gateway Lambda function weighted alias “live” v1 code100% Run PreTraffic hook against v2 code before it receives traffic v2 code0%
  • 59. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy – Lambda canary deployment API Gateway Lambda function weighted alias “live” v1 code90% Wait for 10 minutes, roll back in case of alarm v2 code10%
  • 60. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy – Lambda canary deployment API Gateway Lambda function weighted alias “live” v1 code0% Run PostTraffic hook and complete deployment v2 code100%
  • 61. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. API Gateway canary stage API Gateway Production stage v1 code v2 code 99.5% 0.5% Canary stage
  • 62. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployments • Provisions “green” tasks, then flips traffic at the load balancer • Validation “hooks” enable testing at each stage of the deployment • Fast rollback to “blue” tasks in seconds if case of hook failure or CloudWatch alarms • Monitor deployment status and history via console, API, Amazon SNS notifications, and CloudWatch Events • Use “CodeDeploy-ECS” deploy action in CodePipeline or “aws ecs deploy” command in Jenkins
  • 63. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS appspec version: 1.0 Resources: - TargetService: Type: AWS::ECS::Service Properties: - TaskDefinition: "my_task_definition:8" LoadBalancerInfos: - ContainerName: "SampleApp" ContainerPort: 80 Hooks: - BeforeInstall: "LambdaFunctionToExecuteAnythingBeforeNewRevisionInstalltion" - AfterInstall: "LambdaFunctionToExecuteAnythingAfterNewRevisionInstallation" - AfterAllowTestTraffic: "LambdaFunctionToValidateAfterTestTrafficShift" - BeforeAllowTraffic: "LambdaFunctionToValidateBeforeTrafficShift" - AfterAllowTraffic: "LambdaFunctionToValidateAfterTrafficShift"
  • 64. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployment 100% Prod traffic
  • 65. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployment Target group 2 100% Prod traffic Test traffic listener (port 9000)
  • 66. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployment Green tasks: v2 code 100% Prod traffic Provision green tasks
  • 67. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployment 100% Test traffic 100% Prod traffic Run hook against test endpoint before green tasks receive prod traffic
  • 68. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployment 100% Prod traffic Flip traffic to green tasks, rollback in case of alarm 0% Prod traffic
  • 69. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployment 100% Prod traffic Drain blue tasks
  • 70. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments • Docker tags are resolved when each container starts, not just during deployments • Deploying “latest” or “prod” can result in untested code in production after a scale-out event • Use unique “immutable” tags for deployments
  • 71. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments
  • 72. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments Build pushes new “latest” image Image: sha256@22222... (“latest”)
  • 73. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments Service scales up, launching new tasks Image: sha256@22222... (“latest”)
  • 74. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments Deploy using immutable tags { "name": "sample-app", "image": "amazon/amazon-ecs- sample@sha256:3e39d933b1d948c92309bb583b5a1f3d28f0119e1551ca1fe538ba414a41af48d" } { "name": "sample-app", "image": "amazon/amazon-ecs-sample:build-b2085490-359f-4eaf-8970-6d1e26c354f0" } SHA256 Digest Build ID
  • 75. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments Compute immutable tags during build SHA256 Digest export IMAGE_URI=`docker inspect --format='{{index .RepoDigests 0}}' my_image:$IMAGE_TAG` Example Result: amazon/amazon-ecs-sample@sha256:3e39d933b... Build ID export IMAGE_TAG=build-`echo $CODEBUILD_BUILD_ID | awk –F":" ‘{print $2}'` Example Result: build-b2085490-359f-4eaf-8970-6d1e26c354f0
  • 76. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments
  • 77. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments Build pushes new image tagged with new build ID Image: sha256@22222... (“build-22222”)
  • 78. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments Service scales up, launching new tasks Image: sha256@22222... (“build-22222”)
  • 79. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments Image: “build-22222” tag Deployment updates service’s task definition, replacing tasks Image: sha256@22222... (“build-22222”)
  • 80. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Continuous deployment goals 1. Automatically deploy new changes to staging environments for testing 2. Deploy to production safely without impacting customers 3. Deliver to customers faster: Increase deployment frequency, and reduce change lead time and change failure rate
  • 81. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Continuous deployment
  • 82. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications
  • 83. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 84. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Capital One – Credit Offers API serverless architecture Affiliates www.capitalone.com/ credit-cards/prequalify AWS Cloud Capital One API Gateway VPC Lambda Function Traces Logs Production Support Command Center COAT Credit Offers API Team Lambda Function S3 Bucket TTL Third-Party API
  • 85. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Capital One – Credit Offers API CI/CD pipeline Continuous Improvement, Continuous Delivery! GitHub LGTM Bot Jenkins AWS SAM S3 Bucket (Versioning) Lambda Function DeploymentType: dev: AllAtOnce qa: AllAtOnce qaw: AllAtOnce prod: Canary10Percent10Minutes prodw: Canary10Percent10Minutes canary5xxGetProductsAlarm: Type: AWS::CloudFormation::Alarm Properties: AlarmActions: - !FindInMap: - params - AdminSNSTopic - !Ref Environment AlarmDescription: 500 error from product listing Lambda. ComparisonOperator: GreatherThanOrEqualTothreshold Period: 300 Statistic: Sum Threshold: 1 EvaluationPeriod: 1
  • 86. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Capital One – Benefits from taking the API serverless Performance gains From the time the request is received by lambda to the time to send the response back 70% Cost savings By removing EC2, ELB and RDS from our solution 90% Increase in team velocity Reduce investment in team’s time on DevOps and dedicate back to feature development! 30%
  • 87. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 88. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Demo – Store & Reply AWS Cloud Region https://github.com/danilop/store-and-reply
  • 89. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takeaways 1. Manage your infrastructure as code 2. Frequently build and integrate your code to get a first feedback 3. Continuously release in production using canary releases with monitoring and automated rollbacks 4. Use canary releases to get both technical and business feedback
  • 90. Thank you! © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Danilo Poccia @danilop