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
- Source stage outputs artifacts → stored in pipeline's artifact bucket
- Build stage references those input artifacts by name
- CodeBuild runs using your buildspec
- CodeBuild's artifacts configuration creates output artifacts
- 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.