KC KLOUDCARE
Home Free Assessment LifecycleWatchNew
AWS Cost OptimisationFind and remove wasted spend AWS Solutions ArchitectureDesign and review on AWS AWS DevOps ConsultingTerraform, CI/CD and containers AWS ModernisationReplace legacy tooling and servers AWS Application DevelopmentBackends, APIs and automation Managed AWS SupportOngoing help for your AWS account AWS Security ReviewFind and close security gaps AWS Health CheckExpert review, from £395 All services →
Security Pricing Contact
Blog

AWS CI CD Pipeline Example: CodePipeline, CodeBuild, GitHub

28 November 2026 · 9 min read

Contents
  1. What does a working AWS CI/CD pipeline example look like end to end?
  2. What does the AWS CI/CD pipeline architecture look like as a diagram?
  3. Which AWS CI/CD pipeline services do you actually need (and which can you skip)?
  4. How do you connect GitHub to CodePipeline?
  5. What goes in a working buildspec.yml?
  6. How do you deploy the pipeline itself as code?
  7. What does this cost per month, roughly?
  8. When is DIY the wrong call for a small team?

Key takeaways

  • A minimal AWS CI/CD pipeline needs only CodePipeline, CodeBuild, an AWS CodeConnections connection to GitHub (formerly CodeStar Connections), and an S3 artifact bucket; CodeArtifact and multi-region setups can be skipped.
  • CodeBuild's free tier covers 100 build minutes per month on general1.small or arm1.small, for every account, so a small team's pipeline bill is typically single-digit dollars.
  • Use npm ci instead of npm install, put tests in pre_build, and set base-directory correctly in the artifacts block to avoid wasted build minutes and confusing deploy failures.
  • Define the pipeline, IAM role and artifact bucket in CloudFormation or CDK so the pipeline is versioned, reviewable and reproducible like the rest of your infrastructure.
  • A GitHub connection created by CloudFormation or the CLI starts as pending and needs one approval in the console to complete the handshake.

A working AWS CI CD pipeline example is CodePipeline watching a GitHub repo, CodeBuild running a buildspec.yml to test and package your app, and the pipeline deploying to S3 or ECS on every push. Below is the full setup: annotated architecture, a copyable buildspec.yml, and the pipeline itself as deployable code.

What does a working AWS CI/CD pipeline example look like end to end?

The flow in one sentence: GitHub push to CodePipeline to CodeBuild to deployment

A developer pushes to main. A webhook triggers CodePipeline, which hands the source artifact to CodeBuild. CodeBuild runs your buildspec.yml: install dependencies, run tests, build the container or bundle. The pipeline then deploys to ECS, Lambda, or S3/CloudFront, depending on your stack. The whole chain is defined in CloudFormation or Terraform, so the pipeline itself is versioned code.

Why this stack suits a team without a dedicated cloud engineer

CodePipeline has two pricing types (see the CodePipeline pricing page): V1 pipelines cost $1 per active pipeline per month, with one free, and V2 pipelines cost $0.002 per action execution minute, with 100 free minutes a month. Either way, costs stay predictable at small scale. There is no CI server to patch and no plugins to babysit. If you would rather have someone sanity-check the setup, KloudCare's AWS DevOps consulting runs defined projects at a fixed price, from £750, with the scope agreed before work starts.

What does the AWS CI/CD pipeline architecture look like as a diagram?

Annotated diagram: GitHub webhook, CodePipeline, CodeBuild, artifact store, deploy stage

The flow runs left to right:

GitHub repo
   │  (webhook fires on push to main)
   ▼
CodePipeline (pipeline definition, stages: Source → Build → Deploy)
   │
   ▼
CodeBuild (pulls buildspec.yml, runs tests, outputs build artifact)
   │
   ▼
S3 artifact store (zipped build output, passed between stages)
   │
   ▼
Deploy stage (CodeDeploy to EC2/ASG, or ECS service update)

The GitHub webhook is the only push trigger; everything downstream is pipeline-driven. CodePipeline orchestrates but builds nothing itself, CodeBuild does the work, and the S3 bucket in the middle is the handoff point between stages.

Where state, secrets and artifacts live

Artifacts go in a versioned S3 bucket created alongside the pipeline. The GitHub connection needs no token in your pipeline. Any other secrets the build needs live in Secrets Manager, referenced by name in the buildspec, never committed to the repo. The pipeline definition itself is CloudFormation, so the whole setup is reproducible; the same pipeline-as-code pattern underpins our AWS modernisation work.

Which AWS CI/CD pipeline services do you actually need (and which can you skip)?

CodePipeline vs CodeBuild vs CodeDeploy vs CodeArtifact

ServiceWhat it doesNeed it?
CodePipelineOrchestrates the workflowYes
CodeBuildRuns your build and testsYes
CodeDeployPushes releases to EC2, ECS or LambdaUsually, if you deploy to EC2 or ECS
CodeArtifactPrivate package registrySkip until you have a real reason

CodeBuild is where the minutes are billed. Pricing is per build minute and varies by compute type; the free tier covers 100 build minutes per month on the general1.small instance (AWS CodeBuild pricing). A typical small app build lands well inside that.

What a 5-50 person team can safely ignore

Skip CodeArtifact (GitHub handles package hosting fine at your size), skip extra connections beyond the basic GitHub one, and skip multi-region pipelines. CodeDeploy is worth it only if you deploy to EC2 or ECS; if you ship a container image and ECS pulls it, you can defer it.

The same "buy the minimum" logic applies to the AWS account itself. If you'd rather have someone else build the pipeline plumbing, KloudCare's AWS DevOps consulting takes that work on as a fixed-price project, documented and handed over.

How do you connect GitHub to CodePipeline?

Creating the connection in the console

CodePipeline talks to GitHub through a connection from AWS CodeConnections (the service AWS renamed from CodeStar Connections; older connections keep working), not the old OAuth app. The simplest route is the CodePipeline create-pipeline wizard: choose GitHub (via GitHub App) as the source, connect, and pick the repo and branch. In a template you reference the connection's ARN in the Source stage instead. The connection installs an app on your GitHub organisation, so you can scope it to specific repos. Webhooks fire automatically once the pipeline is created, so pushes to your branch trigger builds without polling.

Why the connection is a CloudFormation resource you should codify

The connection is a CloudFormation resource too (AWS::CodeStarConnections::Connection), which means you can create it in the same template as the pipeline itself. That matters for a small team: a new repo or a rebuilt account is a deploy, not a console archaeology session. A connection created this way starts as pending and needs one approval in the console to complete the GitHub handshake, so keep that step in your runbook. Because the connection grants an external service access to your source repo, review what it can reach and keep your account's broader access tight — the read-only IAM pattern we use at KloudCare applies here too.

What goes in a working buildspec.yml?

Full buildspec.yml with inline comments

version: 0.2

env:
  variables:
    NODE_ENV: production

phases:
  install:
    runtime-versions:
      nodejs: 20
    commands:
      - npm ci
  pre_build:
    commands:
      - npm run lint
      - npm test
  build:
    commands:
      - npm run build

artifacts:
  files:
    - '**/*'
  base-directory: dist

Install, pre_build, build and post_build phases explained

The phases run in order, and the full syntax is documented in the AWS CodeBuild User Guide's buildspec reference. install pins your runtime version and installs dependencies; npm ci beats npm install here because it deletes node_modules first and matches the lockfile exactly. pre_build is where tests and linting belong: if they fail, the pipeline stops before you build anything. build produces the deployable output. Keep deployment out of the buildspec: let the pipeline's Deploy stage (for example the Amazon S3 deploy action) publish the artifact, so a failed build can never ship. artifacts tells CodeBuild which files to hand to the next pipeline stage; get base-directory wrong and your deploy stage receives a nested folder structure instead of your app.

That artifacts block is the part most people get wrong. CodeBuild does not guess what you want to pass downstream; it zips only what you list. If your pipeline's deploy action then expects files at the archive root and you forgot base-directory, CodeBuild happily succeeds and the failure surfaces later, in a deploy stage with a far less helpful error. List your output files explicitly, set base-directory to the build output folder, and test the artifact locally by checking what npm run build actually produces before you wire the deploy step.

Common buildspec mistakes that waste build minutes

Three cost you real time. First, npm install instead of npm ci, which pulls drifting dependency trees and breaks builds weeks later. Second, skipping a buildspec cache config, so every run re-downloads node_modules from scratch; a cache block keyed on a hash of package-lock.json cuts install time sharply on Node projects. Third, running tests inside build rather than pre_build, so a failing test still pays for the compile step. If you would rather hand the whole pipeline, buildspec included, to someone else, KloudCare's DevOps consulting builds it as a fixed-price project.

How do you deploy the pipeline itself as code?

A pipeline configured by clicking through the console is a pipeline only one person can rebuild. Define it in CloudFormation or CDK and it lives in the same repo as your app: versioned, reviewable, and reproducible in any account or region with one deploy.

CloudFormation snippet for the pipeline, role and bucket

The minimum you need is a pipeline resource, an artifact S3 bucket, and an IAM role CodePipeline assumes:

Resources:
  ArtifactsBucket:
    Type: AWS::S3::Bucket
  PipelineRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Action: sts:AssumeRole
            Effect: Allow
            Principal:
              Service: codepipeline.amazonaws.com
      # Policies: a least-privilege inline policy for the artifact bucket,
      # the CodeBuild project and the GitHub connection (never PowerUserAccess)
  Pipeline:
    Type: AWS::CodePipeline::Pipeline
    Properties:
      RoleArn: !GetAtt PipelineRole.Arn
      ArtifactStore:
        Type: S3
        Location: !Ref ArtifactsBucket
      Stages:  # at least two stages: Source, Build (and Deploy); see below
        # ...

This is a skeleton, not a deployable template: give the role a least-privilege inline policy, and fill in the stages. The Stages block wires the GitHub source connection, the CodeBuild action from the previous section, and your deploy target.

CDK alternative in a few lines

CDK collapses the same stack to roughly a dozen lines: an aws_codepipeline.Pipeline with an ArtifactBucket, a PipelineRole, and stage objects for source, build and deploy. The L2 constructs generate the role, bucket and event wiring for you, so the diff stays small when stages change.

Why pipeline-as-code matters when the founder also runs the account

If the person who owns the AWS account also ships product, anything not in code is a bus-factor risk. A committed template means you can recreate the pipeline after an account cleanup, hand it to a new hire, or diff it in a pull request instead of reverse-engineering console settings at 11pm.

What does this cost per month, roughly?

For a small team pushing a handful of builds a day, the pipeline's AWS bill is typically single-digit dollars, dominated by CodeBuild compute minutes rather than CodePipeline itself. Treat any figure here as illustrative; your buildspec's phases determine runtime, and longer test suites are what inflate the bill. The CodeBuild buildspec reference shows which phases you're paying for on every run.

Where costs hide: artifact storage, cross-region, NAT

Three line items surprise founders. S3 versioning on artifacts accumulates old build outputs. Deploying cross-region duplicates transfer and storage. And if you attach CodeBuild to a VPC, AWS requires private subnets and a NAT gateway for internet access, and NAT charges per gigabyte can dwarf everything else. Leave CodeBuild outside your VPC unless the build must reach private resources; if it must, add VPC endpoints (an S3 gateway endpoint is free) to cut NAT traffic.

When is DIY the wrong call for a small team?

Signals you have outgrown console-and-spreadsheet DevOps

The pipeline above takes a day to build and a few hours a month to maintain. The trouble starts when maintenance competes with product work: failed deploys get debugged at 11pm, IAM policies drift from what the CloudFormation template says, and nobody has time to check whether the buildspec still matches reality. If deploys are blocked on one person's calendar, that person is your bottleneck.

How KloudCare works with teams like yours: read-only access, fixed price

KloudCare is an AWS consultancy for UK teams running production workloads without a dedicated cloud engineer. If you want to start small, the free AWS assessment is a read-only scan you run yourself in 10–15 minutes (it is also listed on AWS Marketplace). For an expert review, the AWS Health Check starts at £395: a read-only review with a written report and a prioritised roadmap. Pipeline builds are fixed-price DevOps projects, scoped before work starts.

FAQ

Is AWS CodePipeline free, or what does it cost per month?

A V1 pipeline costs $1 per active pipeline per month (one is free); a V2 pipeline costs $0.002 per action execution minute, with 100 free minutes a month. A new pipeline is V1 unless you choose V2. The bigger line item is CodeBuild, which charges per build minute; its free tier covers 100 minutes per month on general1.small or arm1.small. A small app's builds usually land inside that allowance.

Can I use AWS CI/CD with GitHub instead of CodeCommit?

Yes. CodePipeline connects to GitHub through an AWS CodeConnections connection (formerly CodeStar Connections) rather than the old OAuth app. You create the connection once, install the GitHub app on your organisation, and reference the connection ARN in the pipeline's Source stage. Webhooks fire automatically, so pushes trigger builds without polling, and the connection itself can be defined as CloudFormation.

CodePipeline vs GitHub Actions: which should a small team pick?

If your team already lives in GitHub, GitHub Actions is simpler: one platform, one bill, workflows in the same repo. CodePipeline makes sense when your deploys are AWS-native, like ECS service updates or CodeDeploy to EC2, and you want the pipeline defined as CloudFormation alongside your infrastructure. Many teams run Actions for tests and CodePipeline for deploys.

How long does it take to set up a CI/CD pipeline on AWS?

For a straightforward setup, GitHub source, CodeBuild with a buildspec.yml, and an S3 or ECS deploy, expect about a day if you define everything in CloudFormation or CDK. The GitHub connection needs one approval in the console, which adds minutes, not hours. Ongoing maintenance is typically a few hours a month, mostly buildspec tweaks.

Do I need CodeDeploy if I deploy to ECS or Lambda?

Not for ordinary ECS deployments: CodePipeline's Amazon ECS deploy action updates the service directly. CodeDeploy comes in for blue/green deployments, where it shifts traffic between the old and new versions. For Lambda, CodePipeline can invoke deploy actions directly, so CodeDeploy is optional. If you simply push a container image and let ECS pull it, you can defer CodeDeploy entirely until you need controlled rollouts or rollbacks.

Check your own AWS account

The free AWS assessment is read-only and takes 10–15 minutes. LifecycleWatch tracks your AWS expiry and end-of-support dates every day.

Run the free assessment

← All articles

KCKLOUDCARE

AWS cloud engineering and support for UK businesses.

Tools

Free AWS Assessment LifecycleWatch: AWS end-of-support alerts LifecycleWatch user guide

Services

AWS Cost Optimisation AWS Solutions Architecture AWS DevOps Consulting AWS Modernisation AWS Application Development Managed AWS Support AWS Security Review AWS Health Check

Company

Pricing Contact Security Assessment vs AWS tools Health Check vs large consultancies Privacy Policy Terms

Blog

All KloudCare articles AWS updates that matter (every Monday) Real AWS bill shock stories Real outages from expired certificates Latest: 5 AWS security mistakes in small business accounts

All articles: Medium · dev.to · Hashnode

Get in touch

hello@kloudcare.co.uk +44 7459 524831 Book a call LinkedIn KloudCare on Clutch Facebook Instagram YouTube

167-169 Great Portland Street, 5th Floor, London W1W 5PF

© 2026 KloudCare Limited. Registered in England and Wales, company number 17506352. Registered office: 167-169 Great Portland Street, London, England, W1W 5PF. Member of the AWS Partner Network.