1. Home
  2. Training Library
  3. Developer Tools (DVA-C01)

Working With AWS CodeBuild

Working With AWS CodeBuild
2h 4m

This course provides detail on the AWS Developer Tool services relevant to the Developer - Associate exam.

Want more? Try a lab playground or do a Lab Challenge!

Learning Objectives

  • Introduction to AWS CodeCommit and how it can be used to manage your source code
  • Learn where AWS CodeCommit sits in a CI/CD setup
  • Understand when and where to use CodeCommit within your own development solutions
  • Introduce you to AWS CodeBuild and how it can be used to compile, build, and test your source code
  • Learn where AWS CodeBuild sits in a CI/CD setup
  • Familiarize yourself with the AWS CodeBuild service and ensure you know when and where to use it within your own software projects
  • Understand what AWS CodeDeploy is and when it should be used
  • Learn from a demonstration where we use AWS CodeDeploy to deploy our web portal project onto EC2 infrastructure. 
  • Learn the fundamentals of AWS CodePipeline
  • Understand where CodePipeline the service sits in a CI/CD setup
  • learn how you can use AWS CodePipeline to orchestrate, build and deploy a workflow for a web portal project
  • Understand the key aspects of AWS CodeStar, its benefits, and its use cases
  • Provision a full CI/CD workflow using AWS CodeStar
  • Introduce the AWS X-Ray service and the functionality that it provides.
  • Explain the functions of the AWS X-Ray service and how to use AWS X-Ray with other AWS services.
  • Demonstrate how to use the AWS X-Ray Console - highlighting key areas such as the Service Map and Tracing windows
  • Demonstrate how to implement a Docker-based Node.js application using the AWS X-ray SDK.

- [Instructor] Welcome back. In this lecture, we'll introduce you to AWS CodeBuild and how it can be used to compile, build and test your source code. We'll show you where AWS CodeBuild sits in a CICD setup. This lecture will familiarize yourself with the AWS CodeBuild service and ensure you know when and where to use it within your own software projects. Okay, let's begin. AWS CodeBuild is a fully managed build service. AWS CodeBuild can be used to compile source code to generate build artifacts. For example, CodeBuild can be used to compile Java or .NET source code. Another interesting use case for CodeBuild is where it can be used to build and compile Docker images, then register these into ECR. As we will see later on in this lecture, AWS CodeBuild can be triggered to build automatically off commits made into a CodeCommit repository. More on that later. Beneath the hood, AWS CodeBuild uses Docker containers to manage and execute builds. CodeBuild supports several out of the box preconfigured Docker container build environments: .NET Core, Java, Ruby, Python, Go, NodeJS, Android and Docker are all supported. Regardless of the supported list, you can create your own custom build Docker images preloaded and configured with whatever build tools you require. The resulting custom Docker image is then uploaded into Amazon EC2 Container Registry or the Docker Hub Registry and then becomes available to be configured into your own CodeBuild projects. CodeBuild uses a YAML based BuildSpec file to drive the build. The structure and outline of the BuildSpec file is shown here. Within this file, you specify the build phases or sequence of steps, and then the particular build commands used to tune your source code and to build artifacts. Let's now take a closer look at a couple of examples. In the first example, the BuildSpec file, as shown here, is used to build a Java based application. It first downloads and installed Maven, then uses Maven to download library dependencies, perform complication and packaging. The end result is a JAR file which is referenced as a file within the artifacts section. In this second example, the BuildSpec file instructs CodeBuild to compile a Docker image. The BuildSpec file consists of three build phases, pre-build, build and post-build. Assuming that a Docker file existed in the same directory as this BuildSpec file, CodeBuild will go ahead and build the required Docker image as per the instructions contained within the Docker file. The resulting Docker image is then automatically uploaded and registered into ECR. Several environment variables are injected at build time. As already described, AWS CodeBuild acts as the build or compile system for your software projects. It is the service into which your source code is passed and for which then undergoes a build or compile phase. As we will see in the next lecture, AWS CodePipeline is the service that glues or plumbs AWS CodeCommit and AWS CodeBuild together through the use of a pipeline. When this is set up and configured correctly, commits into a CodeCommit repository will trigger your respective CodeBuild project to kick off and build the expected build artifacts. The steps to provision a new build project within AWS CodeBuild are fairly simple. The key configuration attributes are source provider, the location of your source code. Currently, CodeBuild supports the following source control locations: S3, CodeCommit, Bitbucket, GitHub and GitHub Enterprise. Build container, the Docker build container that will be used to perform the build. This can be selected from a list of preconfigured Docker containers such as .NET Core, Java, Ruby, Python, Go, NodeJS, Android or a custom one that you provide. Artifacts location, the location to which the build artifacts will be stored. Currently only supports S3. AWS CodeBuild provides several integration options. CodeBuild CloudWatch events. CodeBuild publishes events to CloudWatch such that you can detect and react to changes in the state of your build. S3 artifacts. When a build project completes, you have the option to save your build artifacts out to an S3 bucket. You can leverage S3 bucket triggers to trigger other actions. For example, a lambda function to perform some kind of action. BuildSpec file. As we're already seen, the BuildSpec file gives you the capability to hook in commands or custom scripts to be performed at particular times within a build. Okay. That completes this introduction lecture on the AWS CodeBuild service. Go ahead and close this lecture, and we'll see you shortly in the next one.

About the Author
Jeremy Cook
Content Lead Architect
Learning Paths

Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, GCP, Azure), Security, Kubernetes, and Machine Learning.

Jeremy holds professional certifications for AWS, GCP, and Kubernetes.