Slide 1

Slide 1 text

© 2019, Amazon Web Services, inc. or its affiliates. All rights reserved. Introduction to CI/CD in the cloud Scale your dev team from 1 to1000’s deployments per day Sébastien Stormacq C l o u d E x p o E u r o p e 2 0 1 9 Senior Developer Advocate Amazon Web Services, EMEA @sebsto

Slide 2

Slide 2 text

Continuous Integration Workflow Version Control Continuous integration Server Commit to dev branch Pull code Send build report to development team; stop everything if build fails Distributed builds; run tests in parallel Hook Developer Test Types Integration Unit Code coverage

Slide 3

Slide 3 text

Continuous Integration Workflow Commit to dev branch Pull code Send build report to development team; stop everything if build fails Distributed builds; run tests in parallel Hook Test Types Integration Unit Code coverage Developer AWS CodeCommit AWS CodeBuild

Slide 4

Slide 4 text

Anatomy of a buildspec File version: 0.2 phases: pre_build: commands: - echo Logging in to Amazon ECR... - aws --version - $(aws ecr get-login --region eu-west-1 --no-include-email) - REPOSiTORY_URi=486652066693.dkr.ecr.eu-west-1.amazonaws.com/nginx - iMAGE_TAG=$(echo $CODEBUiLD_RESOLVED_SOURCE_VERSiON | cut -c 1-7) build: commands: - echo Build started on `date` - echo Building the Docker image... - docker build -t $REPOSiTORY_URi:latest nginx/. - docker tag $REPOSiTORY_URi:latest $REPOSiTORY_URi:$iMAGE_TAG post_build: commands: - echo Build completed on `date` - echo Pushing the Docker images... - docker push $REPOSiTORY_URi:latest - docker push $REPOSiTORY_URi:$iMAGE_TAG - echo Writing image definitions file... - printf '[{"name":"nginx","imageUri":"%s"}]’ $REPOSiTORY_URi:$iMAGE_TAG > imagedefinitions.json artifacts: files: imagedefinitions.json

Slide 5

Slide 5 text

One Dev Environment Does Not Scale

Slide 6

Slide 6 text

One Dev / Testing Environment per Developer

Slide 7

Slide 7 text

Infrastructure as Code – Avoid Snow Flakes

Slide 8

Slide 8 text

Cloud Development Kit (CDK) AWS CloudFormation template AWS CDK application Stack(s) Construct Construct Resources

Slide 9

Slide 9 text

CDK : Package Your Application CDK : Create a VPC // // create VPC w/ public and private subnets in 2 AZ // this also creates a NAT Gateway // const vpc = new ec2.Vpc(this, 'NewsBlogVPC', { maxAzs : 2 }); // // create static web site as S3 assets // var path = require('path'); const asset = new assets.Asset(this, ’YourSampleApp', { path: path.join(__dirname, '../html') }); // define a user data script to install & launch our app const userData = UserData.forLinux(); userData.addCommands('yum install -y nginx’, 'chkconfig nginx on', 'service nginx start’); userData.addCommands(`aws s3 cp s3://${asset.s3BucketName}/${asset.s3ObjectKey} .`, `unzip *.zip`, `/bin/cp -r -n ${env}/* /usr/share/nginx/html/`); CDK : Bootstrap Your Servers // create an auto scaling group for each environment const asg = new autoscaling.AutoScalingGroup(this, 'YourAppgAutoScalingGroup ' , { vpc, instanceType: ec2.instanceType.of(ec2.instanceClass.BURSTABLE3, ec2.instanceSize.MiCRO), machineimage: new ec2.AmazonLinuximage(), desiredCapacity: 2, role: role, userData: userData }); CDK : Create an Autoscaling Group

Slide 10

Slide 10 text

CDK : Deploy your Own Dev Environment CloudFormation Template “compiler” CDK CLI “processor” “assembly language” “source” synthesize deploy executes

Slide 11

Slide 11 text

Continuous Deployment Merge PR into Trunk Hook Pull code Developer

Slide 12

Slide 12 text

Complex Pipeline Example – Trek10

Slide 13

Slide 13 text

Blue Green Deployment 100% Prod traffic

Slide 14

Slide 14 text

Blue Green Deployment Target group 2 100% Prod traffic

Slide 15

Slide 15 text

Blue Green Deployment Green tasks: v2 code Provision green tasks 100% Prod traffic

Slide 16

Slide 16 text

Blue Green Deployment Run hook against test endpoint before green tasks receive prod traffic 0% Prod traffic 100% Prod traffic

Slide 17

Slide 17 text

Blue Green Deployment Flip traffic to green tasks, rollback in case of alarm 80% Prod traffic 20% Prod traffic

Slide 18

Slide 18 text

Blue Green Deployment Drain blue tasks 0% Prod traffic 100% Prod traffic

Slide 19

Slide 19 text

© 2019, Amazon Web Services, inc. or its affiliates. All rights reserved.

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

© 2019, Amazon Web Services, inc. or its affiliates. All rights reserved.

Slide 22

Slide 22 text

How Amazon does DevOps? (microservices, 2 pizza teams) (governance, templates)

Slide 23

Slide 23 text

© 2019, Amazon Web Services, inc. or its affiliates. All rights reserved.

Slide 24

Slide 24 text

Think Big, Start Small, Iterate Trunk Based Source Code Control AWS CDK Developers Services Delivery pipelines Monitor Build Test Release Monitor Build Test Release Monitor Build Test Release Monitor Build Test Release Monitor Build Test Release

Slide 25

Slide 25 text

impact on dev hiring and retention

Slide 26

Slide 26 text

Go Build! @sebsto

Slide 27

Slide 27 text

Thank you! © 2019, Amazon Web Services, inc. or its affiliates. All rights reserved. Sébastien Stormacq Developer Advocate Amazon Web Services, EMEA @sebsto Jonathan Weiss Senior Manager, Development Tools Amazon Web Services @jweiss