SlideShare une entreprise Scribd logo
1  sur  97
Télécharger pour lire hors ligne
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CI/CD for Serverless and
Containerized Applications
Clare Liguori
Principal Engineer
AWS Container Services
D E V 3 0 9
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
CI/CD for modern applications
Continuous integration
Continuous deployment
Infrastructure as code
Demo
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
What is a modern application?
© 2018, 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
© 2018, 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
© 2018, 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
© 2018, 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
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Release process stages
Source Build Test Production
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Release process stages
Source Build Test Production
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Release process stages
Source Build Test Production
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Release process stages
Source Build Test Production
• Check-in source
code such as .java
files
• Peer review new
code
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Release process stages
Source Build Test Production
• 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Effects of CI/CD
Source: 2018 DORA State of DevOps Report
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Effects of CI/CD
Source: 2018 DORA State of DevOps Report
Deployment frequency Weekly – monthly Hourly – daily
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Effects of CI/CD
Source: 2018 DORA State of DevOps Report
Deployment frequency Weekly – monthly Hourly – daily
Change lead time One – six months One – seven days
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Effects of CI/CD
Source: 2018 DORA State of DevOps Report
Deployment frequency Weekly – monthly Hourly – daily
Change lead time One – six months One – seven days
Change failure rate 46 - 60% 0 - 15%
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Effects of CI/CD
Source: 2018 DORA State of DevOps Report
Deployment frequency Weekly – monthly Hourly – daily
Change lead time One – six months One – seven days
Change failure rate 46 - 60% 0 - 15%
48% of
software
teams
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Continuous
integration
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous integration goals
Source Build Test Production
© 2018, 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
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodePipeline: Supported sources
AWS CodePipeline now uses
Amazon Elastic Container Registry
(Amazon ECR) as a pipeline source
New
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodePipeline: ECR source action
Source code:
“master” branch
ECR repository:
“release” tag
© 2018, 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
© 2018, 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
© 2018, 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
© 2018, 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.yml
--output-template template-output.yml
--s3_bucket $BUCKET
artifacts:
type: zip
files:
- template-output.yml
© 2018, 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
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Continuous
integration
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Continuous
deployment
Continuous
integration
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Continuous deployment goals
Source Build Test Production
© 2018, 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
© 2018, 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, Lambda, or on-premises
servers
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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
© 2018, 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
Hooks:
PreTraffic: !Ref PreTrafficHook
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-Lambda canary deployment
100%
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-Lambda canary deployment
100%
Run hook against v2 code before it receives traffic
0%
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-Lambda canary deployment
90%
Wait for 10 minutes, roll back in case of alarm
10%
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-Lambda canary deployment
0%
Complete deployment
100%
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS CodeDeploy
AWS CodeDeploy now automates
blue-green deployments to AWS
Fargate and Amazon Elastic
Container Service (ECS)
New
© 2018, 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
© 2018, 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"
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployment
100%
Prod
traffic
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployment
Test
traffic
listener
(port 9000)
Target
group 2
100%
Prod
traffic
© 2018, 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
© 2018, 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
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CodeDeploy-ECS blue-green deployment
100%
Prod
traffic
Drain blue tasks
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
Build pushes new “latest” image
Image: sha256@22222... (“latest”)
© 2018, 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”)
© 2018, 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
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Container image tagging for deployments
© 2018, 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”)
© 2018, 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”)
© 2018, 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”)
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Continuous
deployment
Continuous
integration
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Infrastructure
as code
Continuous
deployment
Continuous
integration
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Infrastructure as code goals
Source Build Test Production
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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
© 2018, 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
© 2018, 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/
© 2018, 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: nodejs6.10
CodeUri: src/
Policies: AmazonDynamoDBReadOnlyAccess
Events:
GetResource:
Type: Api
Properties:
Path: /resource/{resourceId}
Method: get
Table:
Type: AWS::Serverless::SimpleTable
© 2018, 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: nodejs6.10
CodeUri: src/
Policies: AmazonDynamoDBReadOnlyAccess
Events:
GetResource:
Type: Api
Properties:
Path: /resource/{resourceId}
Method: get
Table:
Type: AWS::Serverless::SimpleTable
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Use SAM CLI to package and deploy SAM templates
pip install --user aws-sam-cli
sam init
sam build
sam package
sam deploy
New
© 2018, 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 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 CloudFormation
• Supports all CloudFormation resource types
AWS
CDK
https://awslabs.github.io/aws-cdk
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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();
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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();
CDK template
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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();
CDK template
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CDK template
applets:
MyHelloWorldService:
type: @aws-cdk/aws-ecs:LoadBalancedFargateServiceApplet
properties:
image: 'amazon/amazon-ecs-sample'
© 2018, 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
© 2018, 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
});
…
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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();
© 2018, 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
© 2018, 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Infrastructure
as code
Continuous
deployment
Continuous
integration
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pillars of releasing modern applications
Infrastructure
as code
Continuous
deployment
Continuous
integration
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
re:Invent Trivia game
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
re:Invent Trivia game
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
re:Invent Trivia game
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thank you!
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Clare Liguori
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Contenu connexe

Tendances

AWS CodeDeploy, AWS CodePipeline, and AWS CodeCommit: Transforming Software D...
AWS CodeDeploy, AWS CodePipeline, and AWS CodeCommit: Transforming Software D...AWS CodeDeploy, AWS CodePipeline, and AWS CodeCommit: Transforming Software D...
AWS CodeDeploy, AWS CodePipeline, and AWS CodeCommit: Transforming Software D...
Amazon Web Services
 

Tendances (20)

AWS Secrets Manager
AWS Secrets ManagerAWS Secrets Manager
AWS Secrets Manager
 
DevOps and AWS
DevOps and AWSDevOps and AWS
DevOps and AWS
 
DevSecOps and the CI/CD Pipeline
 DevSecOps and the CI/CD Pipeline DevSecOps and the CI/CD Pipeline
DevSecOps and the CI/CD Pipeline
 
From Monolithic to Microservices
From Monolithic to Microservices From Monolithic to Microservices
From Monolithic to Microservices
 
DEVSECOPS.pptx
DEVSECOPS.pptxDEVSECOPS.pptx
DEVSECOPS.pptx
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Deep Dive - CI/CD on AWS
Deep Dive - CI/CD on AWSDeep Dive - CI/CD on AWS
Deep Dive - CI/CD on AWS
 
Amazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for KubernetesAmazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for Kubernetes
 
Monitoring at the Speed of DevOps
Monitoring at the Speed of DevOpsMonitoring at the Speed of DevOps
Monitoring at the Speed of DevOps
 
Infrastructure is code with the AWS CDK - MAD312 - New York AWS Summit
Infrastructure is code with the AWS CDK - MAD312 - New York AWS SummitInfrastructure is code with the AWS CDK - MAD312 - New York AWS Summit
Infrastructure is code with the AWS CDK - MAD312 - New York AWS Summit
 
An Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - WebinarAn Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - Webinar
 
2019 DevSecOps Reference Architectures
2019 DevSecOps Reference Architectures2019 DevSecOps Reference Architectures
2019 DevSecOps Reference Architectures
 
DevOps at Amazon: A Look at Our Tools and Processes
DevOps at Amazon: A Look at Our Tools and ProcessesDevOps at Amazon: A Look at Our Tools and Processes
DevOps at Amazon: A Look at Our Tools and Processes
 
CI/CD on AWS
CI/CD on AWSCI/CD on AWS
CI/CD on AWS
 
An introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel AvivAn introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
 
Chaos Engineering
Chaos EngineeringChaos Engineering
Chaos Engineering
 
AWS Security Week: AWS Secrets Manager
AWS Security Week: AWS Secrets ManagerAWS Security Week: AWS Secrets Manager
AWS Security Week: AWS Secrets Manager
 
Deep Dive into Amazon ECS & Fargate
Deep Dive into Amazon ECS & FargateDeep Dive into Amazon ECS & Fargate
Deep Dive into Amazon ECS & Fargate
 
AWS CodeDeploy, AWS CodePipeline, and AWS CodeCommit: Transforming Software D...
AWS CodeDeploy, AWS CodePipeline, and AWS CodeCommit: Transforming Software D...AWS CodeDeploy, AWS CodePipeline, and AWS CodeCommit: Transforming Software D...
AWS CodeDeploy, AWS CodePipeline, and AWS CodeCommit: Transforming Software D...
 
Introducing AWS Fargate
Introducing AWS FargateIntroducing AWS Fargate
Introducing AWS Fargate
 

Similaire à CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Invent 2018

Similaire à CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Invent 2018 (20)

DevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWSDevOps Spain 2019. Pedro Mendoza-AWS
DevOps Spain 2019. Pedro Mendoza-AWS
 
Improve Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & DeliveryImprove Productivity with Continuous Integration & Delivery
Improve Productivity with Continuous Integration & Delivery
 
Collision 2018: CodeStar for CICD Pipelines
Collision 2018: CodeStar for CICD PipelinesCollision 2018: CodeStar for CICD Pipelines
Collision 2018: CodeStar for CICD Pipelines
 
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...
 
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
 
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 ...
 
Improve productivity with Continuous Integration & Delivery
Improve productivity with Continuous Integration & DeliveryImprove productivity with Continuous Integration & Delivery
Improve productivity with Continuous Integration & Delivery
 
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer ToolsA Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
A Tale of Two Pizzas: Accelerating Software Delivery with AWS Developer Tools
 
CI/CD@Scale
CI/CD@ScaleCI/CD@Scale
CI/CD@Scale
 
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 ...
 
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
 
How to Build a CICD Pipeline with AWS CodeStar
How to Build a CICD Pipeline with AWS CodeStarHow to Build a CICD Pipeline with AWS CodeStar
How to Build a CICD Pipeline with AWS CodeStar
 
CICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdfCICDforModernApplications_Stockholm.pdf
CICDforModernApplications_Stockholm.pdf
 
Continuous Integration Best Practices (DEV319-R1) - AWS re:Invent 2018
Continuous Integration Best Practices (DEV319-R1) - AWS re:Invent 2018Continuous Integration Best Practices (DEV319-R1) - AWS re:Invent 2018
Continuous Integration Best Practices (DEV319-R1) - AWS re:Invent 2018
 
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...
 
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
 
PaaS – From Code to Running Application using AWS Elastic Beanstalk (DEV323) ...
PaaS – From Code to Running Application using AWS Elastic Beanstalk (DEV323) ...PaaS – From Code to Running Application using AWS Elastic Beanstalk (DEV323) ...
PaaS – From Code to Running Application using AWS Elastic Beanstalk (DEV323) ...
 
Community day _aws_ci_cd_v0.2
Community day _aws_ci_cd_v0.2Community day _aws_ci_cd_v0.2
Community day _aws_ci_cd_v0.2
 

Plus de Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon 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 Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon 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
 

Plus 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
 

CI/CD for Serverless and Containerized Applications (DEV309-R1) - AWS re:Invent 2018

  • 1.
  • 2. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CI/CD for Serverless and Containerized Applications Clare Liguori Principal Engineer AWS Container Services D E V 3 0 9
  • 3. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Agenda CI/CD for modern applications Continuous integration Continuous deployment Infrastructure as code Demo
  • 4. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. What is a modern application?
  • 5. © 2018, 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
  • 6. © 2018, 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
  • 7. © 2018, 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
  • 8. © 2018, 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
  • 9. © 2018, 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. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Release process stages Source Build Test Production
  • 11. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Release process stages Source Build Test Production
  • 12. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Release process stages Source Build Test Production
  • 13. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Release process stages Source Build Test Production • Check-in source code such as .java files • Peer review new code
  • 14. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Release process stages Source Build Test Production • 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
  • 15. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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
  • 16. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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
  • 17. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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
  • 18. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Effects of CI/CD Source: 2018 DORA State of DevOps Report
  • 19. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Effects of CI/CD Source: 2018 DORA State of DevOps Report Deployment frequency Weekly – monthly Hourly – daily
  • 20. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Effects of CI/CD Source: 2018 DORA State of DevOps Report Deployment frequency Weekly – monthly Hourly – daily Change lead time One – six months One – seven days
  • 21. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Effects of CI/CD Source: 2018 DORA State of DevOps Report Deployment frequency Weekly – monthly Hourly – daily Change lead time One – six months One – seven days Change failure rate 46 - 60% 0 - 15%
  • 22. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Effects of CI/CD Source: 2018 DORA State of DevOps Report Deployment frequency Weekly – monthly Hourly – daily Change lead time One – six months One – seven days Change failure rate 46 - 60% 0 - 15% 48% of software teams
  • 23. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications
  • 24. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Continuous integration
  • 25. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Continuous integration goals Source Build Test Production
  • 26. © 2018, 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
  • 27. © 2018, 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
  • 28. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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
  • 29. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodePipeline: Supported sources AWS CodePipeline now uses Amazon Elastic Container Registry (Amazon ECR) as a pipeline source New
  • 30. © 2018, 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
  • 31. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodePipeline: ECR source action Source code: “master” branch ECR repository: “release” tag
  • 32. © 2018, 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
  • 33. © 2018, 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
  • 34. © 2018, 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
  • 35. © 2018, 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.yml --output-template template-output.yml --s3_bucket $BUCKET artifacts: type: zip files: - template-output.yml
  • 36. © 2018, 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
  • 37. © 2018, 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
  • 38. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Continuous integration
  • 39. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Continuous deployment Continuous integration
  • 40. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Continuous deployment goals Source Build Test Production
  • 41. © 2018, 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
  • 42. © 2018, 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, Lambda, or on-premises servers
  • 43. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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
  • 44. © 2018, 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 Hooks: PreTraffic: !Ref PreTrafficHook
  • 45. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-Lambda canary deployment 100%
  • 46. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-Lambda canary deployment 100% Run hook against v2 code before it receives traffic 0%
  • 47. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-Lambda canary deployment 90% Wait for 10 minutes, roll back in case of alarm 10%
  • 48. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-Lambda canary deployment 0% Complete deployment 100%
  • 49. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS CodeDeploy AWS CodeDeploy now automates blue-green deployments to AWS Fargate and Amazon Elastic Container Service (ECS) New
  • 50. © 2018, 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
  • 51. © 2018, 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"
  • 52. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployment 100% Prod traffic
  • 53. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployment Test traffic listener (port 9000) Target group 2 100% Prod traffic
  • 54. © 2018, 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
  • 55. © 2018, 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
  • 56. © 2018, 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
  • 57. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CodeDeploy-ECS blue-green deployment 100% Prod traffic Drain blue tasks
  • 58. © 2018, 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
  • 59. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments
  • 60. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments Build pushes new “latest” image Image: sha256@22222... (“latest”)
  • 61. © 2018, 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”)
  • 62. © 2018, 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
  • 63. © 2018, 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
  • 64. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container image tagging for deployments
  • 65. © 2018, 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”)
  • 66. © 2018, 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”)
  • 67. © 2018, 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”)
  • 68. © 2018, 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
  • 69. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Continuous deployment Continuous integration
  • 70. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Infrastructure as code Continuous deployment Continuous integration
  • 71. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Infrastructure as code goals Source Build Test Production
  • 72. © 2018, 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
  • 73. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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. © 2018, 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
  • 75. © 2018, 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/
  • 76. © 2018, 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: nodejs6.10 CodeUri: src/ Policies: AmazonDynamoDBReadOnlyAccess Events: GetResource: Type: Api Properties: Path: /resource/{resourceId} Method: get Table: Type: AWS::Serverless::SimpleTable
  • 77. © 2018, 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: nodejs6.10 CodeUri: src/ Policies: AmazonDynamoDBReadOnlyAccess Events: GetResource: Type: Api Properties: Path: /resource/{resourceId} Method: get Table: Type: AWS::Serverless::SimpleTable
  • 78. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Use SAM CLI to package and deploy SAM templates pip install --user aws-sam-cli sam init sam build sam package sam deploy New
  • 79. © 2018, 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 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 CloudFormation • Supports all CloudFormation resource types AWS CDK https://awslabs.github.io/aws-cdk
  • 80. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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();
  • 81. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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(); CDK template
  • 82. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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(); CDK template
  • 83. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CDK template applets: MyHelloWorldService: type: @aws-cdk/aws-ecs:LoadBalancedFargateServiceApplet properties: image: 'amazon/amazon-ecs-sample'
  • 84. © 2018, 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
  • 85. © 2018, 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 }); …
  • 86. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 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();
  • 87. © 2018, 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
  • 88. © 2018, 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
  • 89. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Infrastructure as code Continuous deployment Continuous integration
  • 90. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pillars of releasing modern applications Infrastructure as code Continuous deployment Continuous integration
  • 91. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 92. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. re:Invent Trivia game
  • 93. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. re:Invent Trivia game
  • 94. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. re:Invent Trivia game
  • 95. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 96. Thank you! © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Clare Liguori
  • 97. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.