DEV Community

Yash Sonawane
Yash Sonawane

Posted on

How to Build a CI/CD Pipeline on AWS with CodePipeline + GitHub ๐Ÿš€

"You mean I can push code to GitHub and AWS will auto-deploy it?!"

Yes. You can. And itโ€™s easier than you think.

In this post, Iโ€™ll walk you through building a complete CI/CD pipeline on AWS using CodePipeline + GitHub โ€” step by step, with simple language, real-life analogies, and practical code snippets.

Whether youโ€™re deploying a static site, Node.js app, or Docker container, this guide will help you go from zero to auto-deploy hero in under 20 minutes.

Letโ€™s roll! ๐ŸŽฏ


๐Ÿง  What is CI/CD (in Human Language)?

CI/CD = Continuous Integration + Continuous Deployment

  • CI: Every time you push code, it's tested and packaged automatically
  • CD: That packaged code gets deployed to your server โ€” no more manual copy-pasting!

Think of it like setting up a robot that listens to GitHub and launches your app every time you update it.


๐Ÿ› ๏ธ Tools Youโ€™ll Use

Tool Purpose
GitHub Where your source code lives
CodePipeline Orchestrates the CI/CD process
CodeBuild Optional: Builds, tests, or packages your app
S3 / EC2 / Lambda / ECS Final deployment destination

๐Ÿงฐ Prerequisites

  • A GitHub repo with your app (even a basic HTML file will work)
  • AWS account with permissions to use CodePipeline, CodeBuild, S3, EC2, etc.
  • Basic knowledge of Git

๐Ÿšฆ Step-by-Step: Create Your First AWS CI/CD Pipeline

Step 1: Connect GitHub to AWS

  1. Go to AWS Console โ†’ CodePipeline
  2. Click Create pipeline
  3. Name your pipeline (e.g., my-awesome-pipeline)
  4. In Source, choose:
  • Provider: GitHub (version 2)
  • Connect your GitHub account
  • Choose your repo + branch

Step 2: Add a Build Stage (Optional)

If you need to compile or test your code:

  • Add a Build stage using AWS CodeBuild
  • Provide a buildspec.yml file in your repo:
version: 0.2
phases:
  build:
    commands:
      - echo "Building..."
      - npm install
      - npm run build
artifacts:
  files:
    - '**/*'
Enter fullscreen mode Exit fullscreen mode

If you're just deploying static files, you can skip this step.

Step 3: Add Deploy Stage

Choose where to deploy:

  • S3 (for static websites)
  • EC2 (via CodeDeploy)
  • ECS / Lambda for containers or serverless

๐Ÿ“ฆ Example: Deploy to S3

  1. Create an S3 bucket
  2. In the Deploy stage, choose "Amazon S3"
  3. Provide the bucket name
  4. AWS will upload your build artifacts automatically

๐ŸŽ‰ Done! Push code to GitHub โ†’ Pipeline triggers โ†’ S3 gets updated


๐Ÿš€ Real-Life Example: Deploying a React App to S3

  1. Add this buildspec.yml to your React repo:
version: 0.2
phases:
  install:
    commands:
      - npm install
  build:
    commands:
      - npm run build
artifacts:
  base-directory: build
  files:
    - '**/*'
Enter fullscreen mode Exit fullscreen mode
  1. Build stage runs npm run build and prepares files
  2. Deploy stage pushes the /build folder to S3

Push to GitHub and watch the magic happen ๐Ÿ”ฎ


๐Ÿง  Why Use CodePipeline?

  • โœ… Fully managed, no servers to maintain
  • โœ… Pay-as-you-go pricing
  • โœ… Deep integration with AWS services
  • โœ… Easy rollback, logs, and versioning

And best of all โ€” no more "it works on my machine" excuses ๐Ÿ’ป๐Ÿ”ฅ


โš ๏ธ CI/CD Best Practices

  • โœ… Use separate pipelines for staging & production
  • โœ… Add tests in the build phase
  • โœ… Use IAM roles โ€” never hardcode AWS keys
  • โœ… Enable notifications with SNS or Slack

๐Ÿ”š Final Thoughts + Bonus Tip

CI/CD isnโ€™t just a buzzword โ€” itโ€™s how modern devs ship fast and ship safe. With GitHub + AWS CodePipeline, you can automate your deployments like a pro.

๐Ÿ’ก Bonus: Use GitHub Webhooks + AWS Lambda for ultra-custom workflows.


๐Ÿ’ฌ Your Turn: What's Your CI/CD Setup?

Have you built a pipeline before? Want help customizing yours?

๐Ÿ‘‡ Drop your repo or share your experience in the comments. Smash โค๏ธ if you found this helpful and share it with a dev buddy building their first app!

Together, let's automate the boring stuff โ€” and focus on building awesome things. ๐Ÿงก

Top comments (0)