SlideShare una empresa de Scribd logo
1 de 94
Descargar para leer sin conexión
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CI/CD best practices for building
modern applications
Leo Zhadanovsky
Principal Solutions Architect
Amazon Web Services
M A D 3 0 1
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Agenda
CI/CD foundations
CI/CD for modern applications
Continuousintegration
Continuousdeployment
Infrastructure as code
S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Release process stages
Source Build Test Production
• Integration tests
with other systems
• Load testing
• UI tests
• Security testing
• Check-in source
code such as .java
files
• Peer review new
code
• Compile code
• Unit tests
• Style checkers
• Create container
images and
function
deployment
packages
• Deployment to
production
environments
• Monitor code in
production to
quickly detect
errors
Source
• Check-in source
code such as .java
files
• Peer review new
code
Build
• Compile code
• Unit tests
• Style checkers
• Create container
images and
function
deployment
packages
Test
• Integration tests
with other systems
• Load testing
• UI tests
• Security testing
Production
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Release process stages
Source Build Test Production
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS Code Services
Source Build Test Deploy Monitor
AWS CodeBuild +
third party
Software release steps:
AWS CodeCommit AWS CodeBuild AWS CodeDeploy
AWS CodePipeline
AWS
CodeStar
AWS X-Ray
Amazon
CloudWatch
S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Approaches to modern application development
• Accelerate the delivery of new, high-quality services
• Simplify environment management
• Reduce the impact of code changes
• Automate operations
• Gain insight across resources and applications
• Protect customers and the business
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Approaches to modern application development
• Accelerate the delivery of new, high-quality services with CI/CD
• Simplify environment management with serverless technologies
• Reduce the impact of code changes with microservice architectures
• Automate operationsby modeling applications& infrastructure as code
• Gain insight across resources and applicationsby enabling observability
• Protect customers and the business with end-to-end security & compliance
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Approaches to modern application development
• Accelerate the delivery of new, high-quality services with CI/CD
• Simplify environment management with serverless technologies
• Reduce the impact of code changes with microservice architectures
• Automate operationsby modeling applications& infrastructure as code
• 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. orits affiliates. All rights reserved.S UM M I T
Effects of CI/CD
Source: 2018 DORA State of DevOps report
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Effects of CI/CD
Source: 2018 DORA State of DevOps report
Deployment frequency Weekly – monthly Hourly – daily
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Effects of CI/CD
Source: 2018 DORA State of DevOps report
Deployment frequency Weekly – monthly Hourly – daily
Change lead time 1–6 months 1–7 days
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Effects of CI/CD
Source: 2018 DORA State of DevOps report
Deployment frequency Weekly – monthly Hourly – daily
Change lead time 1–6 months 1–7 days
Change failure rate 46–60% 0–15%
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Effects of CI/CD
Source: 2018 DORA State of DevOps report
Deployment frequency Weekly – monthly Hourly – daily
Change lead time 1–6 months 1–7 days
Change failure rate 46–60% 0–15%
48% of
software
teams
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Pillars of releasing modern applications
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Pillars of releasing modern applications
Continuous
integration
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Continuous integration goals
Source Build Test Production
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
AWS CodePipeline
• Continuousdelivery service for fast and reliable
applicationupdates
• 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. orits affiliates. All rights reserved.S UM M I T
AWS CodePipeline: Supported sources
Pick branch
AWS CodeCommit
GitHub
Pick object or folder
Amazon Simple
Storage Service
(Amazon S3)
Automatically kick off release and pull latest source code
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS CodePipeline: Supported sources
AWS CodePipeline now uses Amazon
Elastic Container Registry (Amazon
ECR) as a pipeline source
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
AWS CodePipeline: Supported deployment targets
EC2
AWS CodeDeploy
AWS Elastic Beanstalk
AWS OpsWorks stacks
Containers
AWS CodeDeploy
Amazon ECS
Amazon ECS (blue/green)
AWS Fargate
Serverless
AWS CodeDeploy
AWS CloudFormation
(AWS SAM)
AWS Lambda
Automatically kick off release and pull latest source code
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS CodePipeline: ECR source action
Source code:
“master” branch
ECR repository:
“release” tag
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS CodePipeline: Supported triggers
Automatically kick off release
Amazon CloudWatch Events
• Scheduled (nightly release)
• AWS Health events (Fargate
platform retirement)
Available in Amazon CloudWatch
Events console, API, SDK, CLI, and
AWS CloudFormation
Webhooks
• DockerHub
• Quay
• Artifactory
Available in CodePipeline API, SDK, CLI,
and AWS CloudFormation
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Approaches to modern application development
• Accelerate the delivery of new, high-quality services with CI/CD
• Simplify environment management with serverless technologies
• Reduce the impact of code changes with microservice architectures
• Automate operationsby modeling applications& infrastructure as code
• 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. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
AWS CodeBuild: Lambda build specification
version: 0.2
phases:
build:
commands:
- npm ci
- npm test
- >
aws cloudformation package
--template-file template.yml
--output-template template-output.yml
--s3_bucket $BUCKET
artifacts:
type: zip
files:
- template-output.yml
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS CodeBuild: Docker build specification
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. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
Pillars of releasing modern applications
Continuous
integration
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Pillars of releasing modern applications
Continuous
deployment
Continuous
integration
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Continuous deployment goals
Source Build Test Production
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
AWS CodeDeploy
• Automates code deployments to any instance and
Lambda
• Handles the complexity of updating your applications
• Avoid downtime during applicationdeployment
• Roll back automatically if failure detected
• Deploy to Amazon EC2, Lambda, or on-premises
servers
S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.
CodeDeploy-EC2 deployments
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html
permissions:
- object: /var/www/html
pattern: “*.html”
owner: root
group: root
mode: 755
hooks:
ApplicationStop:
- location: scripts/deregister_from_elb.sh
BeforeInstall:
- location: scripts/install_dependencies.sh
ApplicationStart:
- location: scripts/start_httpd.sh
ValidateService:
- location: scripts/test_site.sh
- location: scripts/register_with_elb.sh
S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.
CodeDeploy-EC2 deployments
• Remove/add instance to ELB
• Install dependency packages
• Start Apache
• Confirm successful deploy
• More!
• Send application files to one
directory and configuration
files to another
• Set specific permissions on
specific directories & files
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html
permissions:
- object: /var/www/html
pattern: “*.html”
owner: root
group: root
mode: 755
hooks:
ApplicationStop:
- location: scripts/deregister_from_elb.sh
BeforeInstall:
- location: scripts/install_dependencies.sh
ApplicationStart:
- location: scripts/start_httpd.sh
ValidateService:
- location: scripts/test_site.sh
- location: scripts/register_with_elb.sh
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
v2 v2 v2 v2 v2 v2
One at a time
Half at a time
All at once
v2 v2 v2 v1 v1 v1
v2 v1 v1 v1 v1 v1 Agent
Dev deploymentgroup
OR
Prod deploymentgroup
Choose deployment speed and group
Agent
Agent Agent Agent
Agent Agent Agent
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-Lambda deployments
• Shifts traffic using Lambda function weighted aliases
• Choose canary (“shift 10% of traffic for 10 minutes, then shift rest”) or linear
(“shift 10% more traffic every 10 minutes”)
• Validation“hooks” enable testing at each stage of the deployment
• Fast rollback in seconds if case of hook failure or CloudWatch alarms
• Monitor deployment status and history via console, API, Amazon Simple
Notification Service (Amazon SNS) notifications,and CloudWatch Events
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-Lambda deployments
Enable in your serverless applicationtemplate
Resources:
GetFunction:
Type: AWS::Serverless::Function
Properties:
DeploymentPreference:
Type: Canary10Percent10Minutes
Alarms:
- !Ref ErrorsAlarm
Hooks:
PreTraffic: !Ref PreTrafficHook
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-Lambda canary deployment
100%
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-Lambda canary deployment
100%
Run hook against v2 code before it receives traffic
0%
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-Lambda canary deployment
90%
Wait for 10 minutes, roll back in case of alarm
10%
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-Lambda canary deployment
0%
Complete deployment
100%
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS CodeDeploy
CodeDeploy now automates
blue/green deployments to AWS
Fargate and Amazon Elastic Container
Service (Amazon ECS)
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-ECS blue/green deployment
100%
Prod
traffic
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-ECS blue/green deployment
Test traffic
listener (port
9000)
Target group
2
100%
Prod
traffic
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-ECS blue/green deployment
Green tasks:v2
code
100%
Prod
traffic
Provision green tasks
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-ECS blue/green deployment
100%
Prod
traffic
Flip traffic to green tasks, roll back in case of alarm
0% Prod
traffic
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
CodeDeploy-ECS blue/green deployment
100%
Prod
traffic
Drain blue tasks
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
Container image tagging for deployments
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Container image tagging for deployments
Build pushes new “latest” image
Image: sha256@22222... (“latest”)
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Container image tagging for deployments
Service scales up, launching new tasks
Image: sha256@22222... (“latest”)
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
Container image tagging for deployments
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Container image tagging for deployments
Build pushes new image tagged with new build ID
Image: sha256@22222... (“build-22222”)
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Container image tagging for deployments
Service scales up, launching new tasks
Image: sha256@22222... (“build-22222”)
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
Pillars of releasing modern applications
Continuous
deployment
Continuous
integration
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Approaches to modern application development
• Accelerate the delivery of new, high-quality services with CI/CD
• Simplify environment management with serverless technologies
• Reduce the impact of code changes with microservice architectures
• Automate operationsby modeling applications& infrastructure as code
• 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. orits affiliates. All rights reserved.S UM M I T
Pillars of releasing modern applications
Infrastructure
as code
Continuous
deployment
Continuous
integration
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Infrastructure as code goals
Source Build Test Production
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
Continuous testing with infrastructure as code
Validate an artifact
(Build stage)
• Unit tests
• Static analysis
• Mocked dependencies and
environments
• Vulnerability image scans
Validate an environment
(Test stages)
• Integration tests against real
dependencies and real
environments
• Load testing
• Penetration testing
• Monitoring to test impact of
deployments on environment
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Release infrastructure as code
“Master”
branch
Prepare template Create & execute
change set
Create & execute
change set
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Model function environments with AWS Serverless
Application Model (AWS SAM)
https://aws.amazon.com/serverless/sam/
• Open source framework for building serverless
applicationson AWS
• Shorthandsyntax to express functions, APIs, databases,
and event source mappings
• Transforms and expands AWS SAM syntax into AWS
CloudFormationsyntax on deployment
• Supports all AWS CloudFormationresource types
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS SAM template capabilities
• Can mix in other non-SAMCloudFormationresources 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
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS SAM template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
GetFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.get
Runtime: nodejs6.10
CodeUri: src/
Policies: AmazonDynamoDBReadOnlyAccess
Events:
GetResource:
Type: Api
Properties:
Path: /resource/{resourceId}
Method: get
Table:
Type: AWS::Serverless::SimpleTable
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS SAM template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
GetFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.get
Runtime: nodejs6.10
CodeUri: src/
Policies: AmazonDynamoDBReadOnlyAccess
Events:
GetResource:
Type: Api
Properties:
Path: /resource/{resourceId}
Method: get
Table:
Type: AWS::Serverless::SimpleTable
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Use SAM CLI to package and deploy SAM templates
pip install --user aws-sam-cli
sam init
sam build
sam package
sam deploy
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Model container environments with AWS
Cloud Development Kit (AWS CDK)
Developer
preview
• Open source framework to define cloud infrastructure in
TypeScript
• 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 AWS CloudFormation
• Supports all AWS CloudFormationresource types
AWS
CDK
https://awslabs.github.io/aws-cdk
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS CDK template
import ec2 = require('@aws-cdk/aws-ec2');
import ecs = require('@aws-cdk/aws-ecs');
import cdk = require('@aws-cdk/cdk');
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. orits affiliates. All rights reserved.S UM M I T
AWS CDK template
import ec2 = require('@aws-cdk/aws-ec2');
import ecs = require('@aws-cdk/aws-ecs');
import cdk = require('@aws-cdk/cdk');
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. orits affiliates. All rights reserved.S UM M I T
AWS CDK template
import ec2 = require('@aws-cdk/aws-ec2');
import ecs = require('@aws-cdk/aws-ecs');
import cdk = require('@aws-cdk/cdk');
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. orits affiliates. All rights reserved.S UM M I T
AWS CDK template
applets:
MyHelloWorldService:
type: @aws-cdk/aws-ecs:LoadBalancedFargateServiceApplet
properties:
image: 'amazon/amazon-ecs-sample'
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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
• AWS CDK includes many high-level constructs for modeling a CodePipeline
pipeline, including automatically configuring IAM role policies
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
AWS 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. orits affiliates. All rights reserved.S UM M I T
AWS CDK pipelines: Stack
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();
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Use CDK CLI to synthesize and deploy CDK templates
npm install -g aws-cdk
cdk init app --language typescript
cdk synth
cdk deploy
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
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. orits affiliates. All rights reserved.S UM M I T
Pillars of releasing modern applications
Infrastructure
as code
Continuous
deployment
Continuous
integration
© 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T
Pillars of releasing modern applications
Infrastructure
as code
Continuous
deployment
Continuous
integration
S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.
Thank you!
S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.
Leo Zhadanovsky
S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.

Más contenido relacionado

La actualidad más candente

Add intelligence to applications - AIM205 - Santa Clara AWS Summit.pdf
Add intelligence to applications - AIM205 - Santa Clara AWS Summit.pdfAdd intelligence to applications - AIM205 - Santa Clara AWS Summit.pdf
Add intelligence to applications - AIM205 - Santa Clara AWS Summit.pdfAmazon Web Services
 
Automatic-Labelling-and-Model-Tuning-with-Amazon-SageMaker
Automatic-Labelling-and-Model-Tuning-with-Amazon-SageMakerAutomatic-Labelling-and-Model-Tuning-with-Amazon-SageMaker
Automatic-Labelling-and-Model-Tuning-with-Amazon-SageMakerAmazon Web Services
 
Visually developing IoT applications using AWS IoT Things Graph - SVC207 - Ch...
Visually developing IoT applications using AWS IoT Things Graph - SVC207 - Ch...Visually developing IoT applications using AWS IoT Things Graph - SVC207 - Ch...
Visually developing IoT applications using AWS IoT Things Graph - SVC207 - Ch...Amazon Web Services
 
Developing intelligent robots with AWS RoboMaker - SVC207 - Santa Clara AWS S...
Developing intelligent robots with AWS RoboMaker - SVC207 - Santa Clara AWS S...Developing intelligent robots with AWS RoboMaker - SVC207 - Santa Clara AWS S...
Developing intelligent robots with AWS RoboMaker - SVC207 - Santa Clara AWS S...Amazon Web Services
 
[REPEAT] Optimize your workloads with Amazon EC2 & AMD EPYC - DEM01-R - Santa...
[REPEAT] Optimize your workloads with Amazon EC2 & AMD EPYC - DEM01-R - Santa...[REPEAT] Optimize your workloads with Amazon EC2 & AMD EPYC - DEM01-R - Santa...
[REPEAT] Optimize your workloads with Amazon EC2 & AMD EPYC - DEM01-R - Santa...Amazon Web Services
 
What's new in Amazon Aurora - ADB204 - Santa Clara AWS Summit.pdf
What's new in Amazon Aurora - ADB204 - Santa Clara AWS Summit.pdfWhat's new in Amazon Aurora - ADB204 - Santa Clara AWS Summit.pdf
What's new in Amazon Aurora - ADB204 - Santa Clara AWS Summit.pdfAmazon Web Services
 
Amazon EC2 A1 instances, powered by the AWS Graviton processor - CMP303 - San...
Amazon EC2 A1 instances, powered by the AWS Graviton processor - CMP303 - San...Amazon EC2 A1 instances, powered by the AWS Graviton processor - CMP303 - San...
Amazon EC2 A1 instances, powered by the AWS Graviton processor - CMP303 - San...Amazon Web Services
 
Why AWS for running Microsoft workloads - CMP202-I - New York AWS Summit
Why AWS for running Microsoft workloads - CMP202-I - New York AWS SummitWhy AWS for running Microsoft workloads - CMP202-I - New York AWS Summit
Why AWS for running Microsoft workloads - CMP202-I - New York AWS SummitAmazon Web Services
 
Building enterprise solutions with blockchain technology - SVC217 - New York ...
Building enterprise solutions with blockchain technology - SVC217 - New York ...Building enterprise solutions with blockchain technology - SVC217 - New York ...
Building enterprise solutions with blockchain technology - SVC217 - New York ...Amazon Web Services
 
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...Amazon Web Services
 
Developing serverless applications with .NET using AWS SDK and tools - MAD308...
Developing serverless applications with .NET using AWS SDK and tools - MAD308...Developing serverless applications with .NET using AWS SDK and tools - MAD308...
Developing serverless applications with .NET using AWS SDK and tools - MAD308...Amazon Web Services
 
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
 
Driving Overall Equipment Effectiveness with AWS IoT SiteWise - SVC213 - Chic...
Driving Overall Equipment Effectiveness with AWS IoT SiteWise - SVC213 - Chic...Driving Overall Equipment Effectiveness with AWS IoT SiteWise - SVC213 - Chic...
Driving Overall Equipment Effectiveness with AWS IoT SiteWise - SVC213 - Chic...Amazon Web Services
 
Amazon SageMaker: ML for Every Developer and Data Scientist - AIM202 - Anahei...
Amazon SageMaker: ML for Every Developer and Data Scientist - AIM202 - Anahei...Amazon SageMaker: ML for Every Developer and Data Scientist - AIM202 - Anahei...
Amazon SageMaker: ML for Every Developer and Data Scientist - AIM202 - Anahei...Amazon Web Services
 
Building AR/VR apps with AWS - SVC201 - Santa Clara AWS Summit.pdf
Building AR/VR apps with AWS - SVC201 - Santa Clara AWS Summit.pdfBuilding AR/VR apps with AWS - SVC201 - Santa Clara AWS Summit.pdf
Building AR/VR apps with AWS - SVC201 - Santa Clara AWS Summit.pdfAmazon Web Services
 
The Zen of governance - Establish guardrails and empower builders - SVC201 - ...
The Zen of governance - Establish guardrails and empower builders - SVC201 - ...The Zen of governance - Establish guardrails and empower builders - SVC201 - ...
The Zen of governance - Establish guardrails and empower builders - SVC201 - ...Amazon 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
 
Migliora la disponibilità e le prestazioni delle tue applicazioni con Amazon ...
Migliora la disponibilità e le prestazioni delle tue applicazioni con Amazon ...Migliora la disponibilità e le prestazioni delle tue applicazioni con Amazon ...
Migliora la disponibilità e le prestazioni delle tue applicazioni con Amazon ...Amazon Web Services
 
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...Amazon Web Services
 
Grid computing in the cloud for Financial Services industry - CMP205-I - New ...
Grid computing in the cloud for Financial Services industry - CMP205-I - New ...Grid computing in the cloud for Financial Services industry - CMP205-I - New ...
Grid computing in the cloud for Financial Services industry - CMP205-I - New ...Amazon Web Services
 

La actualidad más candente (20)

Add intelligence to applications - AIM205 - Santa Clara AWS Summit.pdf
Add intelligence to applications - AIM205 - Santa Clara AWS Summit.pdfAdd intelligence to applications - AIM205 - Santa Clara AWS Summit.pdf
Add intelligence to applications - AIM205 - Santa Clara AWS Summit.pdf
 
Automatic-Labelling-and-Model-Tuning-with-Amazon-SageMaker
Automatic-Labelling-and-Model-Tuning-with-Amazon-SageMakerAutomatic-Labelling-and-Model-Tuning-with-Amazon-SageMaker
Automatic-Labelling-and-Model-Tuning-with-Amazon-SageMaker
 
Visually developing IoT applications using AWS IoT Things Graph - SVC207 - Ch...
Visually developing IoT applications using AWS IoT Things Graph - SVC207 - Ch...Visually developing IoT applications using AWS IoT Things Graph - SVC207 - Ch...
Visually developing IoT applications using AWS IoT Things Graph - SVC207 - Ch...
 
Developing intelligent robots with AWS RoboMaker - SVC207 - Santa Clara AWS S...
Developing intelligent robots with AWS RoboMaker - SVC207 - Santa Clara AWS S...Developing intelligent robots with AWS RoboMaker - SVC207 - Santa Clara AWS S...
Developing intelligent robots with AWS RoboMaker - SVC207 - Santa Clara AWS S...
 
[REPEAT] Optimize your workloads with Amazon EC2 & AMD EPYC - DEM01-R - Santa...
[REPEAT] Optimize your workloads with Amazon EC2 & AMD EPYC - DEM01-R - Santa...[REPEAT] Optimize your workloads with Amazon EC2 & AMD EPYC - DEM01-R - Santa...
[REPEAT] Optimize your workloads with Amazon EC2 & AMD EPYC - DEM01-R - Santa...
 
What's new in Amazon Aurora - ADB204 - Santa Clara AWS Summit.pdf
What's new in Amazon Aurora - ADB204 - Santa Clara AWS Summit.pdfWhat's new in Amazon Aurora - ADB204 - Santa Clara AWS Summit.pdf
What's new in Amazon Aurora - ADB204 - Santa Clara AWS Summit.pdf
 
Amazon EC2 A1 instances, powered by the AWS Graviton processor - CMP303 - San...
Amazon EC2 A1 instances, powered by the AWS Graviton processor - CMP303 - San...Amazon EC2 A1 instances, powered by the AWS Graviton processor - CMP303 - San...
Amazon EC2 A1 instances, powered by the AWS Graviton processor - CMP303 - San...
 
Why AWS for running Microsoft workloads - CMP202-I - New York AWS Summit
Why AWS for running Microsoft workloads - CMP202-I - New York AWS SummitWhy AWS for running Microsoft workloads - CMP202-I - New York AWS Summit
Why AWS for running Microsoft workloads - CMP202-I - New York AWS Summit
 
Building enterprise solutions with blockchain technology - SVC217 - New York ...
Building enterprise solutions with blockchain technology - SVC217 - New York ...Building enterprise solutions with blockchain technology - SVC217 - New York ...
Building enterprise solutions with blockchain technology - SVC217 - New York ...
 
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
 
Developing serverless applications with .NET using AWS SDK and tools - MAD308...
Developing serverless applications with .NET using AWS SDK and tools - MAD308...Developing serverless applications with .NET using AWS SDK and tools - MAD308...
Developing serverless applications with .NET using AWS SDK and tools - MAD308...
 
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...
 
Driving Overall Equipment Effectiveness with AWS IoT SiteWise - SVC213 - Chic...
Driving Overall Equipment Effectiveness with AWS IoT SiteWise - SVC213 - Chic...Driving Overall Equipment Effectiveness with AWS IoT SiteWise - SVC213 - Chic...
Driving Overall Equipment Effectiveness with AWS IoT SiteWise - SVC213 - Chic...
 
Amazon SageMaker: ML for Every Developer and Data Scientist - AIM202 - Anahei...
Amazon SageMaker: ML for Every Developer and Data Scientist - AIM202 - Anahei...Amazon SageMaker: ML for Every Developer and Data Scientist - AIM202 - Anahei...
Amazon SageMaker: ML for Every Developer and Data Scientist - AIM202 - Anahei...
 
Building AR/VR apps with AWS - SVC201 - Santa Clara AWS Summit.pdf
Building AR/VR apps with AWS - SVC201 - Santa Clara AWS Summit.pdfBuilding AR/VR apps with AWS - SVC201 - Santa Clara AWS Summit.pdf
Building AR/VR apps with AWS - SVC201 - Santa Clara AWS Summit.pdf
 
The Zen of governance - Establish guardrails and empower builders - SVC201 - ...
The Zen of governance - Establish guardrails and empower builders - SVC201 - ...The Zen of governance - Establish guardrails and empower builders - SVC201 - ...
The Zen of governance - Establish guardrails and empower builders - SVC201 - ...
 
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 ...
 
Migliora la disponibilità e le prestazioni delle tue applicazioni con Amazon ...
Migliora la disponibilità e le prestazioni delle tue applicazioni con Amazon ...Migliora la disponibilità e le prestazioni delle tue applicazioni con Amazon ...
Migliora la disponibilità e le prestazioni delle tue applicazioni con Amazon ...
 
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
Deploy and scale your first cloud application with Amazon Lightsail - CMP202 ...
 
Grid computing in the cloud for Financial Services industry - CMP205-I - New ...
Grid computing in the cloud for Financial Services industry - CMP205-I - New ...Grid computing in the cloud for Financial Services industry - CMP205-I - New ...
Grid computing in the cloud for Financial Services industry - CMP205-I - New ...
 

Similar a AWS CodePipeline CI/CD Best Practices

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 - 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 - 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
 
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
 
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
 
DevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWSDevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWSatSistemas
 
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
 
CICDforModernApplications-Oslo.pdf
CICDforModernApplications-Oslo.pdfCICDforModernApplications-Oslo.pdf
CICDforModernApplications-Oslo.pdfAmazon Web Services
 
CICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdfCICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdfAmazon Web Services
 
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
 
Making CI/CD pipelines safer with application monitoring and tracing - MAD202...
Making CI/CD pipelines safer with application monitoring and tracing - MAD202...Making CI/CD pipelines safer with application monitoring and tracing - MAD202...
Making CI/CD pipelines safer with application monitoring and tracing - MAD202...Amazon Web Services
 
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...Amazon Web Services
 
CI CD using AWS Developer Tools @ AWS Community Day Chennai 2019
CI CD using AWS Developer Tools @ AWS Community Day Chennai 2019CI CD using AWS Developer Tools @ AWS Community Day Chennai 2019
CI CD using AWS Developer Tools @ AWS Community Day Chennai 2019Bhuvaneswari Subramani
 
20201012 - Serverless Architecture Conference - Deploying serverless applicat...
20201012 - Serverless Architecture Conference - Deploying serverless applicat...20201012 - Serverless Architecture Conference - Deploying serverless applicat...
20201012 - Serverless Architecture Conference - Deploying serverless applicat...Marcia Villalba
 
Modern Applications Development on AWS
Modern Applications Development on AWSModern Applications Development on AWS
Modern Applications Development on AWSBoaz Ziniman
 
Improve Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & DeliveryImprove Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & DeliveryAmazon Web Services
 
Improve Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & DeliveryImprove Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & DeliveryAmazon Web Services
 
Build CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesAmazon Web Services
 
AWS Accra Meetup - Developing Modern Applications in the Cloud
AWS Accra Meetup - Developing Modern Applications in the CloudAWS Accra Meetup - Developing Modern Applications in the Cloud
AWS Accra Meetup - Developing Modern Applications in the CloudCobus Bernard
 

Similar a AWS CodePipeline CI/CD Best Practices (20)

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 - 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 - 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...
 
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...
 
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
 
DevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWSDevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWS
 
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
 
CICDforModernApplications-Oslo.pdf
CICDforModernApplications-Oslo.pdfCICDforModernApplications-Oslo.pdf
CICDforModernApplications-Oslo.pdf
 
CICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdfCICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdf
 
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
 
CI/CD for Modern Applications
CI/CD for Modern ApplicationsCI/CD for Modern Applications
CI/CD for Modern Applications
 
Making CI/CD pipelines safer with application monitoring and tracing - MAD202...
Making CI/CD pipelines safer with application monitoring and tracing - MAD202...Making CI/CD pipelines safer with application monitoring and tracing - MAD202...
Making CI/CD pipelines safer with application monitoring and tracing - MAD202...
 
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Inve...
 
CI CD using AWS Developer Tools @ AWS Community Day Chennai 2019
CI CD using AWS Developer Tools @ AWS Community Day Chennai 2019CI CD using AWS Developer Tools @ AWS Community Day Chennai 2019
CI CD using AWS Developer Tools @ AWS Community Day Chennai 2019
 
20201012 - Serverless Architecture Conference - Deploying serverless applicat...
20201012 - Serverless Architecture Conference - Deploying serverless applicat...20201012 - Serverless Architecture Conference - Deploying serverless applicat...
20201012 - Serverless Architecture Conference - Deploying serverless applicat...
 
Modern Applications Development on AWS
Modern Applications Development on AWSModern Applications Development on AWS
Modern Applications Development on AWS
 
Improve Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & DeliveryImprove Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & Delivery
 
Improve Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & DeliveryImprove Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & Delivery
 
Build CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation Slides
 
AWS Accra Meetup - Developing Modern Applications in the Cloud
AWS Accra Meetup - Developing Modern Applications in the CloudAWS Accra Meetup - Developing Modern Applications in the Cloud
AWS Accra Meetup - Developing Modern Applications in the Cloud
 

Más de 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
 

Más de 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 CodePipeline CI/CD Best Practices

  • 1. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CI/CD best practices for building modern applications Leo Zhadanovsky Principal Solutions Architect Amazon Web Services M A D 3 0 1
  • 2. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Agenda CI/CD foundations CI/CD for modern applications Continuousintegration Continuousdeployment Infrastructure as code
  • 3. S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.
  • 4. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Release process stages Source Build Test Production • Integration tests with other systems • Load testing • UI tests • Security testing • Check-in source code such as .java files • Peer review new code • Compile code • Unit tests • Style checkers • Create container images and function deployment packages • Deployment to production environments • Monitor code in production to quickly detect errors Source • Check-in source code such as .java files • Peer review new code Build • Compile code • Unit tests • Style checkers • Create container images and function deployment packages Test • Integration tests with other systems • Load testing • UI tests • Security testing Production
  • 5. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Release process stages Source Build Test Production
  • 6. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS Code Services Source Build Test Deploy Monitor AWS CodeBuild + third party Software release steps: AWS CodeCommit AWS CodeBuild AWS CodeDeploy AWS CodePipeline AWS CodeStar AWS X-Ray Amazon CloudWatch
  • 7. S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.
  • 8. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Approaches to modern application development • Accelerate the delivery of new, high-quality services • Simplify environment management • Reduce the impact of code changes • Automate operations • Gain insight across resources and applications • Protect customers and the business
  • 9. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Approaches to modern application development • Accelerate the delivery of new, high-quality services with CI/CD • Simplify environment management with serverless technologies • Reduce the impact of code changes with microservice architectures • Automate operationsby modeling applications& infrastructure as code • Gain insight across resources and applicationsby enabling observability • Protect customers and the business with end-to-end security & compliance
  • 10. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Approaches to modern application development • Accelerate the delivery of new, high-quality services with CI/CD • Simplify environment management with serverless technologies • Reduce the impact of code changes with microservice architectures • Automate operationsby modeling applications& infrastructure as code • 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. orits affiliates. All rights reserved.S UM M I T Effects of CI/CD Source: 2018 DORA State of DevOps report
  • 12. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Effects of CI/CD Source: 2018 DORA State of DevOps report Deployment frequency Weekly – monthly Hourly – daily
  • 13. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Effects of CI/CD Source: 2018 DORA State of DevOps report Deployment frequency Weekly – monthly Hourly – daily Change lead time 1–6 months 1–7 days
  • 14. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Effects of CI/CD Source: 2018 DORA State of DevOps report Deployment frequency Weekly – monthly Hourly – daily Change lead time 1–6 months 1–7 days Change failure rate 46–60% 0–15%
  • 15. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Effects of CI/CD Source: 2018 DORA State of DevOps report Deployment frequency Weekly – monthly Hourly – daily Change lead time 1–6 months 1–7 days Change failure rate 46–60% 0–15% 48% of software teams
  • 16. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Pillars of releasing modern applications
  • 17. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Pillars of releasing modern applications Continuous integration
  • 18. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Continuous integration goals Source Build Test Production
  • 19. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 20. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodePipeline • Continuousdelivery service for fast and reliable applicationupdates • 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
  • 21. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodePipeline: Supported sources Pick branch AWS CodeCommit GitHub Pick object or folder Amazon Simple Storage Service (Amazon S3) Automatically kick off release and pull latest source code
  • 22. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodePipeline: Supported sources AWS CodePipeline now uses Amazon Elastic Container Registry (Amazon ECR) as a pipeline source
  • 23. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 24. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodePipeline: Supported deployment targets EC2 AWS CodeDeploy AWS Elastic Beanstalk AWS OpsWorks stacks Containers AWS CodeDeploy Amazon ECS Amazon ECS (blue/green) AWS Fargate Serverless AWS CodeDeploy AWS CloudFormation (AWS SAM) AWS Lambda Automatically kick off release and pull latest source code
  • 25. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodePipeline: ECR source action Source code: “master” branch ECR repository: “release” tag
  • 26. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodePipeline: Supported triggers Automatically kick off release Amazon CloudWatch Events • Scheduled (nightly release) • AWS Health events (Fargate platform retirement) Available in Amazon CloudWatch Events console, API, SDK, CLI, and AWS CloudFormation Webhooks • DockerHub • Quay • Artifactory Available in CodePipeline API, SDK, CLI, and AWS CloudFormation
  • 27. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Approaches to modern application development • Accelerate the delivery of new, high-quality services with CI/CD • Simplify environment management with serverless technologies • Reduce the impact of code changes with microservice architectures • Automate operationsby modeling applications& infrastructure as code • Gain insight across resources and applications by enabling observability • Protect customers and the business with end-to-end security & compliance
  • 28. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 29. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 30. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 31. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodeBuild: Lambda build specification version: 0.2 phases: build: commands: - npm ci - npm test - > aws cloudformation package --template-file template.yml --output-template template-output.yml --s3_bucket $BUCKET artifacts: type: zip files: - template-output.yml
  • 32. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodeBuild: Docker build specification 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
  • 33. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 34. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Pillars of releasing modern applications Continuous integration
  • 35. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Pillars of releasing modern applications Continuous deployment Continuous integration
  • 36. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Continuous deployment goals Source Build Test Production
  • 37. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 38. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodeDeploy • Automates code deployments to any instance and Lambda • Handles the complexity of updating your applications • Avoid downtime during applicationdeployment • Roll back automatically if failure detected • Deploy to Amazon EC2, Lambda, or on-premises servers
  • 39. S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved. CodeDeploy-EC2 deployments version: 0.0 os: linux files: - source: / destination: /var/www/html permissions: - object: /var/www/html pattern: “*.html” owner: root group: root mode: 755 hooks: ApplicationStop: - location: scripts/deregister_from_elb.sh BeforeInstall: - location: scripts/install_dependencies.sh ApplicationStart: - location: scripts/start_httpd.sh ValidateService: - location: scripts/test_site.sh - location: scripts/register_with_elb.sh
  • 40. S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved. CodeDeploy-EC2 deployments • Remove/add instance to ELB • Install dependency packages • Start Apache • Confirm successful deploy • More! • Send application files to one directory and configuration files to another • Set specific permissions on specific directories & files version: 0.0 os: linux files: - source: / destination: /var/www/html permissions: - object: /var/www/html pattern: “*.html” owner: root group: root mode: 755 hooks: ApplicationStop: - location: scripts/deregister_from_elb.sh BeforeInstall: - location: scripts/install_dependencies.sh ApplicationStart: - location: scripts/start_httpd.sh ValidateService: - location: scripts/test_site.sh - location: scripts/register_with_elb.sh
  • 41. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T v2 v2 v2 v2 v2 v2 One at a time Half at a time All at once v2 v2 v2 v1 v1 v1 v2 v1 v1 v1 v1 v1 Agent Dev deploymentgroup OR Prod deploymentgroup Choose deployment speed and group Agent Agent Agent Agent Agent Agent Agent
  • 42. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-Lambda deployments • Shifts traffic using Lambda function weighted aliases • Choose canary (“shift 10% of traffic for 10 minutes, then shift rest”) or linear (“shift 10% more traffic every 10 minutes”) • Validation“hooks” enable testing at each stage of the deployment • Fast rollback in seconds if case of hook failure or CloudWatch alarms • Monitor deployment status and history via console, API, Amazon Simple Notification Service (Amazon SNS) notifications,and CloudWatch Events
  • 43. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-Lambda deployments Enable in your serverless applicationtemplate Resources: GetFunction: Type: AWS::Serverless::Function Properties: DeploymentPreference: Type: Canary10Percent10Minutes Alarms: - !Ref ErrorsAlarm Hooks: PreTraffic: !Ref PreTrafficHook
  • 44. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-Lambda canary deployment 100%
  • 45. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-Lambda canary deployment 100% Run hook against v2 code before it receives traffic 0%
  • 46. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-Lambda canary deployment 90% Wait for 10 minutes, roll back in case of alarm 10%
  • 47. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-Lambda canary deployment 0% Complete deployment 100%
  • 48. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CodeDeploy CodeDeploy now automates blue/green deployments to AWS Fargate and Amazon Elastic Container Service (Amazon ECS)
  • 49. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 50. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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"
  • 51. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-ECS blue/green deployment 100% Prod traffic
  • 52. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-ECS blue/green deployment Test traffic listener (port 9000) Target group 2 100% Prod traffic
  • 53. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-ECS blue/green deployment Green tasks:v2 code 100% Prod traffic Provision green tasks
  • 54. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-ECS blue/green deployment 100% Test traffic 100% Prod traffic Run hook against test endpoint before green tasks receive prod traffic
  • 55. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-ECS blue/green deployment 100% Prod traffic Flip traffic to green tasks, roll back in case of alarm 0% Prod traffic
  • 56. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T CodeDeploy-ECS blue/green deployment 100% Prod traffic Drain blue tasks
  • 57. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 58. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Container image tagging for deployments
  • 59. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Container image tagging for deployments Build pushes new “latest” image Image: sha256@22222... (“latest”)
  • 60. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Container image tagging for deployments Service scales up, launching new tasks Image: sha256@22222... (“latest”)
  • 61. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 62. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 63. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Container image tagging for deployments
  • 64. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Container image tagging for deployments Build pushes new image tagged with new build ID Image: sha256@22222... (“build-22222”)
  • 65. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Container image tagging for deployments Service scales up, launching new tasks Image: sha256@22222... (“build-22222”)
  • 66. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Container image tagging for deployments Image: “build-22222” tag Deployment updates service’s task definition, replacing tasks Image: sha256@22222... (“build-22222”)
  • 67. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 68. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Pillars of releasing modern applications Continuous deployment Continuous integration
  • 69. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Approaches to modern application development • Accelerate the delivery of new, high-quality services with CI/CD • Simplify environment management with serverless technologies • Reduce the impact of code changes with microservice architectures • Automate operationsby modeling applications& infrastructure as code • Gain insight across resources and applications by enabling observability • Protect customers and the business with end-to-end security & compliance
  • 70. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Pillars of releasing modern applications Infrastructure as code Continuous deployment Continuous integration
  • 71. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Infrastructure as code goals Source Build Test Production
  • 72. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 73. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Continuous testing with infrastructure as code Validate an artifact (Build stage) • Unit tests • Static analysis • Mocked dependencies and environments • Vulnerability image scans Validate an environment (Test stages) • Integration tests against real dependencies and real environments • Load testing • Penetration testing • Monitoring to test impact of deployments on environment
  • 74. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Release infrastructure as code “Master” branch Prepare template Create & execute change set Create & execute change set
  • 75. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Model function environments with AWS Serverless Application Model (AWS SAM) https://aws.amazon.com/serverless/sam/ • Open source framework for building serverless applicationson AWS • Shorthandsyntax to express functions, APIs, databases, and event source mappings • Transforms and expands AWS SAM syntax into AWS CloudFormationsyntax on deployment • Supports all AWS CloudFormationresource types
  • 76. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS SAM template capabilities • Can mix in other non-SAMCloudFormationresources 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
  • 77. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS SAM template AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Resources: GetFunction: Type: AWS::Serverless::Function Properties: Handler: index.get Runtime: nodejs6.10 CodeUri: src/ Policies: AmazonDynamoDBReadOnlyAccess Events: GetResource: Type: Api Properties: Path: /resource/{resourceId} Method: get Table: Type: AWS::Serverless::SimpleTable
  • 78. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS SAM template AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Resources: GetFunction: Type: AWS::Serverless::Function Properties: Handler: index.get Runtime: nodejs6.10 CodeUri: src/ Policies: AmazonDynamoDBReadOnlyAccess Events: GetResource: Type: Api Properties: Path: /resource/{resourceId} Method: get Table: Type: AWS::Serverless::SimpleTable
  • 79. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Use SAM CLI to package and deploy SAM templates pip install --user aws-sam-cli sam init sam build sam package sam deploy
  • 80. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Model container environments with AWS Cloud Development Kit (AWS CDK) Developer preview • Open source framework to define cloud infrastructure in TypeScript • 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 AWS CloudFormation • Supports all AWS CloudFormationresource types AWS CDK https://awslabs.github.io/aws-cdk
  • 81. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CDK template import ec2 = require('@aws-cdk/aws-ec2'); import ecs = require('@aws-cdk/aws-ecs'); import cdk = require('@aws-cdk/cdk'); 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();
  • 82. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CDK template import ec2 = require('@aws-cdk/aws-ec2'); import ecs = require('@aws-cdk/aws-ecs'); import cdk = require('@aws-cdk/cdk'); 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();
  • 83. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CDK template import ec2 = require('@aws-cdk/aws-ec2'); import ecs = require('@aws-cdk/aws-ecs'); import cdk = require('@aws-cdk/cdk'); 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();
  • 84. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CDK template applets: MyHelloWorldService: type: @aws-cdk/aws-ecs:LoadBalancedFargateServiceApplet properties: image: 'amazon/amazon-ecs-sample'
  • 85. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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 • AWS CDK includes many high-level constructs for modeling a CodePipeline pipeline, including automatically configuring IAM role policies
  • 86. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS 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 }); …
  • 87. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T AWS CDK pipelines: Stack 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();
  • 88. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Use CDK CLI to synthesize and deploy CDK templates npm install -g aws-cdk cdk init app --language typescript cdk synth cdk deploy
  • 89. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T 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
  • 90. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Pillars of releasing modern applications Infrastructure as code Continuous deployment Continuous integration
  • 91. © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.S UM M I T Pillars of releasing modern applications Infrastructure as code Continuous deployment Continuous integration
  • 92. S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.
  • 93. Thank you! S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved. Leo Zhadanovsky
  • 94. S UM M I T © 2019, Amazon Web Services, Inc. orits affiliates. All rights reserved.