AWS CodeBuild

AWS CodeBuild is a continuous integration service within Amazon Web Services used to compile source code, run tests, and build packages for deployment. It is part of the AWS Code Services family alongside AWS CodeDeploy and AWS CodePipeline — and, for existing customers, AWS CodeCommit — which together provide complete, automated continuous integration and delivery (CI/CD).

Key points

  • Provides prepackaged and customized build environments for many programming languages and tools.
  • Scales automatically to process multiple separate builds concurrently.
  • Can be used as a build or test stage of a pipeline in AWS CodePipeline.
  • Requires a VPC ID, VPC subnet IDs, and VPC security group IDs to access resources inside an Amazon VPC to perform a build or test.
  • Can be run through: the AWS CodeBuild console, the AWS CodePipeline console, the AWS Command Line Interface (CLI), or AWS SDKs.
  • Sits at the Build and Test action categories of a AWS CodePipeline stage — CodePipeline stages are user-defined, not a fixed five-stage model.
  • buildspec.yml is the file that defines a build: a YAML document, either committed as buildspec.yml in the root of the source repository or specified inline/overridden when the build project is created or started, that lists the build phases and the commands to run in each.
  • Standard build phases, run in order: install (install dependencies and runtimes), pre_build (commands before the build, such as logging in to a container registry), build (the actual compile/test/package commands), and post_build (commands after the build, such as tagging and pushing a Docker image).
  • A build project bundles everything CodeBuild needs for a build: the source location (e.g. GitHub, Bitbucket, Amazon S3, or — for existing customers only — AWS CodeCommit, which stopped onboarding new customers in July 2024), the build environment (a runtime/OS image), the compute type (an instance size such as BUILD_GENERAL1_SMALL/_MEDIUM/_LARGE, or a Lambda/reserved-capacity option), and the buildspec. There are no build servers to provision or manage — CodeBuild allocates the environment per build and tears it down afterward.
  • Build artifacts (the compiled/packaged output) are pushed to Amazon S3; build logs are sent to CloudWatch Logs.
  • CodeBuild vs. CodeDeploy vs. CodePipeline — CodeBuild compiles source code, runs tests, and produces build artifacts; AWS CodeDeploy takes already-built artifacts and deploys them to EC2, Lambda, ECS, or on-premises servers; AWS CodePipeline orchestrates the end-to-end release workflow, typically chaining a source stage (GitHub, Bitbucket, S3, ECR, or CodeCommit) → CodeBuild (build/test) → CodeDeploy (deploy) into automated stages.

Pricing

  • Charges are applied based on the amount of time taken by AWS CodeBuild to complete the build — pay only for build duration, with no idle compute to pay for between builds.

Sources