Blue/Green Deployment for Autoscaling Groups with CodePipeline, CodeBuild and CodeDeploy (Part 4/7)

Leon Jalfon
RhinOps by Sela
Published in
3 min readApr 30, 2020

In this 7-parts tutorial we will create an initial environment composed by an autoscaling group with two ubuntu machines behind a load balancer, then we will create a CI/CD pipeline to provide blue/green deployments using CodeBuild, CodeDeploy and CodePipeline.

Part 4: Configure CodeBuild

In this section we will configure a CodeBuild project that will update the “index.html” to add the build Id

About CodeBuild

AWS CodeBuild is a fully managed build service that compiles source code, runs tests, and produces software packages that are ready to deploy. With CodeBuild, you don’t need to provision, manage, and scale your own build servers. CodeBuild scales continuously and processes multiple builds concurrently, so your builds are not left waiting in a queue.

Configure a CodeBuild Project

Browse to “Build projects” (under Build) in the CodeBuild portal and click on “Create build project”

In the “Project configuration” name the build as “bluegreen-build”

In the “Source” section set the following details:

  • Source provider: GitHub
  • Repository: Repository in my GitHub account
  • Github repository: /
  • Source version: master

Under “Primary source webhook events” set:

  • Enable checkbox “Rebuild every time a code change is pushed to this repository”
  • Event type: PUSH

Configure the “Environment” section with the following details:

  • Environment Image: Managed image
  • Operating system: Ubuntu
  • Runtimes: Standard
  • Image: aws/codebuild/standard:4.0
  • Image version: Always use the latest image for this runtime version
  • Environment type: Linux
  • Service role: Existing service role
  • Role ARN: select “bluegreen-codebuild-role”

Under “Buildspec” choose “Use a buildspec file”

In the “Artifacts” section set the type as “No artifacts”

Under “Logs” keep enable the CloudWatch logs and set the following parameters:

  • Group name: bluegreen
  • Stream name: codebuild

Finally test the build by click on “Start build” (keep default values)

You will be redirected to the build log page

--

--