Course contentsShow
← Cloud and Infrastructure
Lesson 1842 of 2,98938. AWS Native CI/CDFree lesson

Build Stage with CodeBuild Integration

Integrating CodeBuild as a build action and passing artifacts between pipeline stages.

Build Stage with CodeBuild Integration

What you'll learn: How to add a CodeBuild action to your pipeline's build stage and manage artifacts that flow between pipeline stages.

The Build Stage's Role

In CodePipeline, the build stage transforms your source code into deployable artifacts. Think of it as the factory floor in a manufacturing line—raw materials (source code) come in, get processed, and finished products (compiled binaries, Docker images, etc.) come out ready for deployment.

Integrating CodeBuild as a Build Action

When you add a build stage to your pipeline, you specify CodeBuild as the action provider. The pipeline automatically:

  • Pulls artifacts from the previous stage (typically your source stage)
  • Invokes your CodeBuild project with those input artifacts
  • Captures the output artifacts CodeBuild produces

The key configuration elements include:

  • Action name: Identifier for this build action
  • Input artifacts: Name referencing the source stage's output (e.g., SourceOutput)
  • CodeBuild project: Which project contains your buildspec
  • Output artifacts: Name you assign (e.g., BuildOutput) for downstream stages

Artifact Flow Between Stages

Artifacts act as the handoff mechanism between pipeline stages. The source stage creates SourceOutput, your build action consumes it, and produces BuildOutput. Later stages (like deploy) then consume BuildOutput.

CodePipeline stores these artifacts in S3 automatically. Each artifact is a compressed archive containing files from that stage—you're simply defining what goes in and what name to call it.

Configuration Flow

  1. Source stage outputs artifacts → stored in pipeline's artifact bucket
  2. Build stage references those input artifacts by name
  3. CodeBuild runs using your buildspec
  4. CodeBuild's artifacts configuration creates output artifacts
  5. Pipeline captures output artifacts for the next stage

Key Takeaway: The build stage bridges source and deployment by consuming source artifacts, running CodeBuild to transform them, and producing deployment-ready output artifacts that flow automatically to subsequent pipeline stages.