Delivery pipelines: CodeBuild, CodeDeploy and CodePipeline

Intermediate · 23 min

AWS's CI/CD services: buildspec files, pipeline stages and artifacts, execution modes, deployment strategies, rollback, and the roles involved.

Before thisWorkload identity for EC2, Lambda and CIChanging stacks safelyECS task definitions and services

DheerajTechInsight · 23 min

Delivery pipelines: CodeBuild, CodeDeploy and CodePipeline

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by DheerajTechInsightReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • CodeBuild runs your build commands, CodeDeploy rolls a revision out, and CodePipeline orders the stages and passes artifacts between them.
  • A buildspec.yml in the repository defines the build phases, the secrets to fetch and the files to keep.
  • Build an artifact once and promote the same one through environments.
  • A pipeline stage holds one execution at a time. In the default SUPERSEDED mode a newer change can overtake an older one that is waiting.
  • Connect deployments to CloudWatch alarms so that rollback does not depend on someone watching.
  • The pipeline can change production, so its roles, approvals and source connection are a security boundary.

From commit to running

The ideas of continuous delivery and pipeline stages and gates apply whatever tool you use. This lesson is the AWS-native set, which earns its place when you want deployment to stay inside your account, under IAM, logged by CloudTrail.

Three services, three jobs. Think of a factory: CodeBuild is the workstation that makes the part, CodeDeploy is the crew that installs it, and CodePipeline is the conveyor that moves it between them.

CodeBuild

CodeBuild starts a fresh build environment, runs your commands and throws the environment away. The commands live in buildspec.yml:

version: 0.2
env:
  parameter-store:
    NPM_TOKEN: /ci/npm-token
phases:
  install:
    runtime-versions:
      nodejs: 24
    commands:
      - npm ci
  build:
    commands:
      - npm test
      - npm run build
  post_build:
    commands:
      - test "$CODEBUILD_BUILD_SUCCEEDING" = 1
      - ./scripts/publish.sh "$CODEBUILD_RESOLVED_SOURCE_VERSION"
artifacts:
  files:
    - dist/**/*

The env block pulls a secret from Parameter Store at run time. The guard in post_build matters, because that phase is not a safe place to assume success. Tag what you publish with the commit, so you can always say what is running.

CodePipeline

A pipeline is a series of stages (Source, Build, Deploy to staging, Approve, Deploy to production), each holding actions that run in sequence or parallel. Actions pass artifacts, stored in S3. For GitHub and similar sources, use a CodeConnections connection, not a personal token.

A stage processes one execution at a time. The execution mode decides what waits: SUPERSEDED (the default) lets newer changes overtake older ones; QUEUED processes every one in order; PARALLEL runs them independently. The last two need a V2 pipeline, and parallel mode can’t use stage rollback. A stage can be configured to roll back to the last execution that succeeded there.

Add a manual approval where a human decision is real. For infrastructure, have one action create a change set and a later one execute it, so the approver sees what will change. Build once and promote that artifact; rebuilding per environment means testing one thing and shipping another.

CodeDeploy

CodeDeploy installs a revision onto one of three platforms, described by an AppSpec file and a deployment group:

  • EC2 or on-premises: in place, one or half the instances at a time, or blue/green. The default configuration is one at a time.
  • Lambda: shift an alias between versions, canary, linear or all at once.
  • ECS: run a replacement task set and move load balancer traffic to it. ECS now also does blue/green itself, so check that first for new services.

Lifecycle hooks run your checks at set points. Automatic rollback, on failure or on a CloudWatch alarm, redeploys the previous revision as a new deployment. A database migration that already ran is not undone, so keep schema changes backward compatible.

Securing the conveyor

Each part has a role: the pipeline, each build project, the deployment. Give a build that runs untrusted pull requests no route to production. Keep the production deploy role in a separate account and let the pipeline assume it. Encrypt artifacts and protect the branch that triggers releases.

A note on CodeCommit and alternatives

AWS closed CodeCommit, its Git hosting, to new customers in July 2024 and reopened it in November 2025, so older advice that it is retired is out of date. CodeCatalyst is closed to new customers. Many teams keep code and CI elsewhere and deploy with OIDC federation, which is a perfectly good design.

Triggers and repeat builds

A V2 pipeline can filter what starts it: pushes to chosen branches, Git tags or file paths, and pull request events. In a repository with several services, path filters stop a documentation change from redeploying everything. Builds start from a clean environment each time, so configure a cache for dependency downloads if builds are slow, and keep the cache an optimisation: a build must still succeed without it.

About the video

The embed is DheerajTechInsight’s “AWS Devops CodePipeline Deep Dive”, March 2026, 23 minutes. Its chapters cover the coordination problem, what CodePipeline is, the stages, how a pipeline works, artifact flow and advanced features such as parallel and cross-Region actions. It centres on CodePipeline; buildspec and CodeDeploy detail is better from this page and the docs. I judged it from chapters and description only, since transcripts couldn’t be fetched. English was judged from the “English (US) original” audio track. A short console build is in deeper.

What was run: only a YAML parse of the buildspec. No build, pipeline or deployment ran; behaviour is from the AWS docs, checked 2026-11-29.

Where this fits

Delivery is done. The last group is about running what you shipped, starting with CloudWatch metrics and alarms.

Check yourself

  1. 01Three commits land within a minute. Will every one reach production through a default pipeline?

    Not necessarily. The default mode is SUPERSEDED, where a newer execution replaces one waiting to enter a stage. Use QUEUED mode, on a V2 pipeline, if every change must be processed in order.

  2. 02Your post_build phase pushed an image even though the tests failed. How?

    A post_build phase can still run after a failed build phase. Guard publishing steps by checking CODEBUILD_BUILD_SUCCEEDING, or publish only from a later pipeline stage.

  3. 03Why is a pipeline in another tool, such as GitHub Actions, not a security shortcut compared with CodePipeline?

    Either way something holds permission to change production. With external CI, use OIDC federation to get short-lived role credentials limited to the right repository and branch, not stored access keys.

  4. 04Where should the database password for an integration test come from in CodeBuild?

    From the buildspec's parameter-store or secrets-manager mapping, with the build role allowed to read only that value. Plaintext environment variables are visible in the console and API.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark