🚀 Create a Complete CI/CD Pipeline Using AWS ECR & ECS
In this article, I am explaining a complete step-by-step process to create a CI/CD pipeline using AWS services like ECR, ECS (Fargate), CodeBuild, GitHub, and CodePipeline. This guide is perfect for beginners who want to deploy a Dockerized application on AWS.
GitHub → CodeBuild → Amazon ECR → Amazon ECS (Fargate) → Live Application
🔹 AWS Services Used (Definitions)
Amazon ECR (Elastic Container Registry)
Amazon ECR is a fully managed Docker container registry that allows you to store, manage, and deploy Docker images securely.
Amazon ECS (Elastic Container Service)
Amazon ECS is a container orchestration service used to run and manage Docker containers. We are using Fargate, which removes the need to manage servers.
AWS CodeBuild
AWS CodeBuild is a fully managed build service that compiles source code, builds Docker images,
and runs commands defined inside a buildspec.yml file.
AWS CodeCommit / GitHub
CodeCommit is AWS’s Git-based repository service. In this project, we are using GitHub as the source repository.
AWS CodePipeline
AWS CodePipeline is a CI/CD service that automates the build, test, and deployment process.
🧩 Step 1: Create or Fork GitHub Repository
Create a GitHub repository or fork my existing repository:
👉 https://github.com/shivaconceptsolution/ecs-ecr-example
This repository contains:
- Dockerfile
- index.html
- buildspec.yml
🧩 Step 2: Create ECS Cluster (Fargate)
- Go to Amazon ECS
- Create a new Cluster
- Select Fargate only
- Provide a cluster name and create
- Create Service under Cluser
- Create task defination to follow step 3 under cluster
🧩 Step 3: Create Task Definition
- Go to Task Definitions → Create New
- Select Launch type: Fargate
- Container Name: Same as Cluster Name
- Image URI: Add ECR URL later
🧩 Step 4: Create ECR Repository
- Go to Amazon ECR
- Create Repository
- Copy the Repository URI
🧩 Step 5: Update Task Definition with ECR Image
- Paste ECR Repository URI in container image
- Save and register the task definition
🧩 Step 6: Create ECS Service
- Open ECS Cluster
- Create Service
- Select Task Definition Family
- Enter Service Name
🧩 Step 7: Create CodeBuild Project
- Go to CodeBuild → Create Project
- Select Source Provider: GitHub
- Create New Service Role
- Attach ECR, ECS, CodeBuild permissions in IAM
🧩 Step 8: Configure BuildSpec
- Select "Use a buildspec file"
- File name: buildspec.yml
🧩 Step 9: Create CodePipeline
- Create Pipeline
- Execution Mode: Queued
- Source: GitHub
- Build Provider: CodeBuild
- Deploy Provider: Amazon ECS
🧩 Step 10: Access Your Application
- Go to ECS → Cluster → Tasks
- Open running task
- Copy Public IP
- Paste in browser

0 Comments
POST Answer of Questions and ASK to Doubt