announcing aws codebuild - january 2017 online teck talks

76
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Chris Munns, Business Development Manager - DevOps January 2017 DevOps on AWS Announcing AWS CodeBuild

Upload: amazon-web-services

Post on 21-Jan-2017

139 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Announcing AWS CodeBuild - January 2017 Online Teck Talks

© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Chris Munns, Business Development Manager - DevOps

January 2017

DevOps on AWSAnnouncing AWS CodeBuild

Page 2: Announcing AWS CodeBuild - January 2017 Online Teck Talks

https://secure.flickr.com/photos/mgifford/4525333972

Why are we here today?

Page 3: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Software moves faster today

Software creation and distribution is easier and faster than ever:• Startups can now take on giants with little to

no funding ahead of time• Getting your software into the hands of

millions is a download away• Your ability to move fast is paramount to your

ability to fight off disruption

Page 4: Announcing AWS CodeBuild - January 2017 Online Teck Talks

What tools do you need to move fast?

Releasing software in this new software driven world requires a number of tools:• Tools to manage the flow of your software development

release process• Tools to properly test and inspect your code for defects

and potential issues• Tools to deploy your applications

Page 5: Announcing AWS CodeBuild - January 2017 Online Teck Talks

• Integration tests with other systems

• Load testing• UI tests• Penetration

testing

Release processes have four major phases

Source Build Test Production

• Check-in source code such as .java files.

• Peer review new code

• Compile code• Unit tests• Style checkers • Code metrics• Create

container images

• Deployment to production environments

Page 6: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Release processes levels

Source Build Test Production

Continuous integration

Continuous delivery

Continuous deployment

Page 7: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS Code* Services

NEW!

NEW!

AWS CodePipeline AWS CodeCommit AWS CodeBuildAWS CodeDeploy

Page 8: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS Code Services

Source Build Test Production

Software Release Steps:

Page 9: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS Code Services

Source Build Test Production

Software Release Steps:

AWS CodeCommit

Page 10: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS Code Services

Source Build Test Production

Software Release Steps:

AWS CodeBuild

Page 11: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS Code Services

Source Build Test Production

Software Release Steps:

Third PartyTooling

Page 12: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS Code Services

Source Build Test Production

Software Release Steps:

AWS CodeDeploy

Page 13: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS Code Services

Source Build Test Production

Software Release Steps:

EC2 On-Prem

AWS CodeDeploy

Page 14: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS Code Services

Source Build Test Production

Software Release Steps:AWS CodePipeline

Page 15: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS Code Services

Source Build Test Production

Third PartyTooling

Software Release Steps:

AWS CodeCommit AWS CodeBuild AWS CodeDeploy

AWS CodePipeline

Page 16: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Build & test your application

https://secure.flickr.com/photos/spenceyc/7481166880

Page 17: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Fully managed build service that compiles source code, runs tests, and produces software packages

Scales continuously and processes multiple builds concurrently

You can provide custom build environments suited to your needs via Docker images

Only pay by the minute for the compute resources you use

Launched with CodePipeline and Jenkins integration

AWS CodeBuild

NEW!

NEW!

Page 18: Announcing AWS CodeBuild - January 2017 Online Teck Talks

How does it work?

1. Downloads source code2. Executes commands configured in the buildspec in

temporary compute containers (created fresh on every build)

3. Streams the build output to the service console and CloudWatch logs

4. Uploads the generated artifact to an S3 bucket

Page 19: Announcing AWS CodeBuild - January 2017 Online Teck Talks

How can I automate my release process with CodeBuild?

• Integrated with AWS CodePipeline for CI/CD

• Easily pluggable (API/CLI driven)

• Bring your own build environments

• Create Docker images containing tools you need

• Open source Jenkins plugin

• Use CodeBuild as the workers off of a Jenkins master

Page 20: Announcing AWS CodeBuild - January 2017 Online Teck Talks

buildspec.yml Exampleversion: 0.1

environment_variables: plaintext: JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64"

phases: install: commands: - apt-get update -y - apt-get install -y maven pre_build: commands: - echo Nothing to do in the pre_build phase... build: commands: - echo Build started on `date` - mvn install post_build: commands: - echo Build completed on `date`artifacts: type: zip files: - target/messageUtil-1.0.jar discard-paths: yes

Page 21: Announcing AWS CodeBuild - January 2017 Online Teck Talks

buildspec.yml Exampleversion: 0.1

environment_variables: plaintext: JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64"

phases: install: commands: - apt-get update -y - apt-get install -y maven pre_build: commands: - echo Nothing to do in the pre_build phase... build: commands: - echo Build started on `date` - mvn install post_build: commands: - echo Build completed on `date`artifacts: type: zip files: - target/messageUtil-1.0.jar discard-paths: yes

• Variables to be used by phases of build

• Examples for what you can do in the phases of a build:

• You can install packages or run commands to prepare your environment in ”install”.

• Run syntax checking, commands in “pre_build”.

• Execute your build tool/command in “build”

• Test your app further or ship a container image to a repository in post_build

• Create and store an artifact in S3

Page 22: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Building Your Code

“Building” code typically refers to languages that require compiled binaries:• .NET languages: C#, F#, VB.net, etc.• Java and JVM languages: Java, Scala,

JRuby• Go• iOS languages: Swift, Objective-CWe also refer to the process of creating Docker container images as “building” the image.

EC2

Page 23: Announcing AWS CodeBuild - January 2017 Online Teck Talks

No Building Required!

Many languages don’t require building. These are considered interpreted languages:• PHP• Ruby• Python• Node.js

You can just deploy your code!

EC2

Page 24: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Testing Your Code

Testing is both a science and an art form!Goals for testing your code:• Want to confirm desired functionality• Catch programming syntax errors• Standardize code patterns and format• Reduce bugs due to non-desired application

usage and logic failures• Make applications more secure

Page 25: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Where to Focus Your Tests:UI

Service

Unit70%

20%

10%

Page 26: Announcing AWS CodeBuild - January 2017 Online Teck Talks

What service and release step corresponds with which tests?

UI

Service

Unit

Third PartyTooling

AWS CodeBuild

Bui

ldTe

st

Page 27: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Pricing

• Pay by the Minute• Three compute types differentiated by the amount of

memory and CPU resources:

• Free tier of 100 build minutes

Compute instance type Memory (GB) vCPU Price per build minute ($)build.general1.small 3 2 0.005

build.general1.medium 7 4 0.010

build.general1.large 15 8 0.020

*As of January 20 2017

Page 28: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Deploying your applications

https://secure.flickr.com/photos/simononly/15386966677

Page 29: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Automates code deployments to any instance

Handles the complexity of updating your applications

Avoid downtime during application deployment

Rollback automatically if failure detected

Deploy to Amazon EC2 or on-premises servers, in any language and on any operating system

Integrates with third-party tools and AWS

AWS CodeDeploy

Page 30: Announcing AWS CodeBuild - January 2017 Online Teck Talks

appspec.yml Exampleversion: 0.0os: linuxfiles: - source: / destination: /var/www/htmlpermissions: - object: /var/www/html pattern: “*.html” owner: root group: root mode: 755hooks: 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

Page 31: Announcing AWS CodeBuild - January 2017 Online Teck Talks

appspec.yml Exampleversion: 0.0os: linuxfiles: - source: / destination: /var/www/htmlpermissions: - object: /var/www/html pattern: “*.html” owner: root group: root mode: 755hooks: 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

• 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

Page 32: Announcing AWS CodeBuild - January 2017 Online Teck Talks

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 Agent

Dev Deployment group

ORProd Deployment group

Agent

AgentAgent

Agent Agent

Agent

Choose Deployment Speed and Group

Page 33: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Orchestrating build and deploy with a pipeline

https://www.flickr.com/photos/seattlemunicipalarchives/12504672623/

Page 34: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Continuous delivery service for fast and reliable application updates

Model and visualize your software release process

Builds, tests, and deploys your code every time there is a code change

Integrates with third-party tools and AWS

AWS CodePipeline

Page 35: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Source

SourceGitHub

Build

CodeBuildAWS CodeBuild

Deploy

JavaAppElastic Beanstalk

PipelineStage

Action

Transition

CodePipelineMyApplication

Page 36: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Build

CodeBuildAWS CodeBuild

NotifyDevelopersLambda

Parallel actions

Source

SourceGitHub

CodePipelineMyApplication

Deploy

JavaAppElastic Beanstalk

Page 37: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Build

CodeBuildAWS CodeBuild

NotifyDevelopersLambda

TestAPIRunscope

Sequential actions

Deploy

JavaAppElastic Beanstalk

Source

SourceGitHub

CodePipelineMyApplication

Page 38: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Build

CodeBuildAWS CodeBuild

Staging-Deploy

JavaAppElastic Beanstalk

Prod-Deploy

JavaAppElastic Beanstalk

QATeamReviewManual Approval Manual Approvals

Review

CodePipelineMyApplication

Page 39: Announcing AWS CodeBuild - January 2017 Online Teck Talks

DEMO!

Page 40: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Demo:

1. Start with a repository (github.com/awslabs/aws-codedeploy-sample-tomcat)

2. Add buildspec.yml3. Create CodePipeline pipeline with a Source and Build

stage4. Do a build5. Add a deploy stage6. Do a full execution of the pipeline

Page 41: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 42: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 43: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 44: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 45: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 46: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 47: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 48: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 49: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 50: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 51: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Demo:

Start with a repository (github.com/awslabs/aws-codedeploy-sample-tomcat)

Add buildspec.yml Create CodePipeline pipeline with a Source and Build

stage Do a build• Add a deploy stage• Do a full execution of the pipeline

Page 52: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 53: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 54: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 55: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 56: Announcing AWS CodeBuild - January 2017 Online Teck Talks
Page 57: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Demo:

Start with a repository (github.com/awslabs/aws-codedeploy-sample-tomcat)

Add buildspec.yml Create CodePipeline pipeline with a Source and Build

stage Do a build Add a deploy stage Do a full execution of the pipeline

Page 58: Announcing AWS CodeBuild - January 2017 Online Teck Talks

General Best Practices used by Amazon Developers

• CI/CD is a MUST!• Commit frequently• Builds on every commit• Build once in a given execution flow• Deploy to a running environment for further testing

Page 59: Announcing AWS CodeBuild - January 2017 Online Teck Talks

General Best Practices used by Amazon Developers

• CI/CD is a MUST!• Commit frequently• Builds on every commit• Build once in a given execution flow• Deploy to a running environment for further testing

• Everything that is code (application, infrastructure, documentation) goes into a repository

• If its not in a repository, it doesn’t go into Production environments!

Page 60: Announcing AWS CodeBuild - January 2017 Online Teck Talks

General Best Practices used by Amazon Developers

• CI/CD is a MUST!• Commit frequently• Builds on every commit• Build once in a given execution flow• Deploy to a running environment for further testing

• Everything that is code (application, infrastructure, documentation) goes into a repository

• If its not in a repository, it doesn’t go into production environments!• Start with continuous delivery (“gated” promotion) and build up to

continuous deployment once evidence of a high-level of excellence in testing is clear

Page 61: Announcing AWS CodeBuild - January 2017 Online Teck Talks

General Best Practices used by Amazon Developers

• CI/CD is a MUST!• Commit frequently• Builds on every commit• Build once in a given execution flow• Deploy to a running environment for further testing

• Everything that is code (application, infrastructure, documentation) goes into a repository

• If its not in a repository, it doesn’t go into production environments!• Start with continuous delivery (“gated” promotion) and build up to

continuous deployment once evidence of a high-level of excellence in testing is clear

• Deploy to canaries, test, deploy to an AZ, test, deploy to a Region, test

Page 62: Announcing AWS CodeBuild - January 2017 Online Teck Talks

General Best Practices used by Amazon Developers (cont.)

• Code Reviews are one of the best mechanisms for “good” code:• Does this code look clean and can someone else understand it?• Is the design of it meeting the expectations of its needs?• Are there better/easier ways to do this same thing?

Page 63: Announcing AWS CodeBuild - January 2017 Online Teck Talks

General Best Practices used by Amazon Developers (cont.)

• Code Reviews are one of the best mechanisms for “good” code:• Does this code look clean and can someone else understand it?• Is the design of it meeting the expectations of its needs?• Are there better/easier ways to do this same thing?

• Style checkers• Will someone else in the company be able to update/fix/maintain this code?

Page 64: Announcing AWS CodeBuild - January 2017 Online Teck Talks

General Best Practices used by Amazon Developers (cont.)

• Code Reviews are one of the best mechanisms for “good” code:• Does this code look clean and can someone else understand it?• Is the design of it meeting the expectations of its needs?• Are there better/easier ways to do this same thing?

• Style checkers• Will someone else in the company be able to update/fix/maintain this code?

• Auto-rollbacks can be the quickest recovery mechanism after failure• Rollback first, then debug what went wrong with logs/graphs/etc.

Page 65: Announcing AWS CodeBuild - January 2017 Online Teck Talks

General Best Practices used by Amazon Developers (cont.)

• Code Reviews are one of the best mechanisms for “good” code:• Does this code look clean and can someone else understand it?• Is the design of it meeting the expectations of its needs?• Are there better/easier ways to do this same thing?

• Style checkers• Will someone else in the company be able to update/fix/maintain this code?

• Auto-rollbacks can be the quickest recovery mechanism after failure• Rollback first, then debug what went wrong with logs/graphs/etc.

• Thorough dashboards• What is happening now?• What ”normal” looks like typically over some period of time?• What do I do if this graph looks wrong/an alarm has been triggered?• What events can I correlate with a move in a graph?

Page 66: Announcing AWS CodeBuild - January 2017 Online Teck Talks

Code* Tips and Tricks

• All Code* products can(and should) be provisioned and managed with AWS CloudFormation!

• You could literally store the CloudFormation templates that provision your Code* resources in CodeCommit and update them via CodePipeline (It’s like Code* Inception!)

• Deep integration with IAM. You can assign permissions on who can commit code, approve manual approvals, deploy to certain deployment groups and more!

• Integrate with AWS Lambda to do almost anything:• CodeCommit has Repository Triggers• CodeDeploy has Event Notifications• CodePipeline has native Lambda invoke

AWS CodePipeline AWS CodeCommit AWS CodeBuildAWS CodeDeploy

Page 67: Announcing AWS CodeBuild - January 2017 Online Teck Talks

FIN, ACKWe’ve quickly reviewed and gone through the benefits of AWS CodeBuild, the newest AWS Code* service:

Page 68: Announcing AWS CodeBuild - January 2017 Online Teck Talks

FIN, ACK

Fully Managed Continuous Scaling Pay as You Go

Enables CI/CDExtensible Secure

We’ve quickly reviewed and gone through the benefits of AWS CodeBuild, the newest AWS Code* service:

AWS CodeBuild eliminates the need to set up, patch, update, and manage

your own build servers and software. There is no software to install or

manage.

Page 69: Announcing AWS CodeBuild - January 2017 Online Teck Talks

FIN, ACK

Fully Managed Continuous Scaling Pay as You Go

Enables CI/CDExtensible Secure

We’ve quickly reviewed and gone through the benefits of AWS CodeBuild, the newest AWS Code* service:

AWS CodeBuild scales automatically to meet your build volume. It immediately processes each build you submit and can run separate

builds concurrently, which means your builds are not left waiting in a queue.

Page 70: Announcing AWS CodeBuild - January 2017 Online Teck Talks

FIN, ACK

Fully Managed Continuous Scaling Pay as You Go

Enables CI/CDExtensible Secure

We’ve quickly reviewed and gone through the benefits of AWS CodeBuild, the newest AWS Code* service:

With AWS CodeBuild, you are charged based on the number of minutes it takes to complete your build. This

means you no longer have to worry about paying for idle build server

capacity.

Page 71: Announcing AWS CodeBuild - January 2017 Online Teck Talks

FIN, ACK

Fully Managed Continuous Scaling Pay as You Go

Enables CI/CDExtensible Secure

We’ve quickly reviewed and gone through the benefits of AWS CodeBuild, the newest AWS Code* service:

You can bring your own build tools and programming runtimes to use with

AWS CodeBuild by creating customized build environments in

addition to the prepackaged build tools and runtimes supported by CodeBuild.

Page 72: Announcing AWS CodeBuild - January 2017 Online Teck Talks

FIN, ACK

Fully Managed Continuous Scaling Pay as You Go

Enables CI/CDExtensible Secure

We’ve quickly reviewed and gone through the benefits of AWS CodeBuild, the newest AWS Code* service:

AWS CodeBuild belongs to a family of AWS Code Services, which you can use to create complete,

automated software release workflows for continuous integration and delivery (CI/CD). You can also integrate

CodeBuild into your existing CI/CD workflow.

Page 73: Announcing AWS CodeBuild - January 2017 Online Teck Talks

FIN, ACK

Fully Managed Continuous Scaling Pay as You Go

Enables CI/CDExtensible Secure

We’ve quickly reviewed and gone through the benefits of AWS CodeBuild, the newest AWS Code* service:

With AWS CodeBuild, your build artifacts are encrypted with customer-specific keys that are managed by the

AWS Key Management Service (KMS). CodeBuild is integrated with

AWS Identity and Access Management (IAM), so you can assign user-specific

permissions to your build projects.

Page 74: Announcing AWS CodeBuild - January 2017 Online Teck Talks

aws.amazon.com/devops

Page 75: Announcing AWS CodeBuild - January 2017 Online Teck Talks

AWS DevOps Blog

Page 76: Announcing AWS CodeBuild - January 2017 Online Teck Talks

?https://secure.flickr.com/photos/dullhunk/202872717/