Part 3: Continuous Deployment with AWS CodeDeploy (Integrating with CodePipeline)

🌱 Just a fresher, vibin’ through tech life. ☁️ Cloud & DevOps rookie, tryna get my hands dirty with real stuff. 🛠️ Writing blogs in my own chill style ’cause most guides feel way too pro-level. 🚀 Learning, breaking, fixing, and sharing my journey—no sugarcoat, just raw curiosity.
Hello techies ,
Welcome back to the AWS CI/CD series!
In Part 1, we built the Continuous Integration (CI) flow using CodePipeline + CodeBuild to automatically build and push our application.
Now in this part, we’ll move one step ahead:
👉 Implement Continuous Deployment (CD) with AWS CodeDeploy, and finally integrate it with CodePipeline to achieve a complete AWS CI/CD workflow.
Step 1: Create a CodeDeploy Application
Login to the AWS Console → CodeDeploy.
Click Create Application.
Select EC2/On-Premises as the compute platform.
Provide a name and create the application.

Step 2: Launch an EC2 Instance (Deployment Target)
Since we’re deploying to EC2 in this demo:
Launch an EC2 instance.
Add a tag (for CodeDeploy to identify it):
Key:
NameValue:
simple-app

Step 3: Configure IAM Roles
We need two roles:
Role for EC2 → To talk to CodeDeploy
- Attach AmazonEC2RoleforAWSCodeDeploy (or
AmazonEC2FullAccessfor demo).
- Attach AmazonEC2RoleforAWSCodeDeploy (or
Role for CodeDeploy → To deploy to EC2
- Attach AWSCodeDeployRole (or full access for demo).
👉 Attach these roles via the IAM Console or directly while creating resources.


Step 4: Install CodeDeploy Agent on EC2
The CodeDeploy Agent must be installed on your EC2 instance so that it can receive deployments.
Run the following on your EC2 instance:
sudo apt update -y
sudo apt install ruby-full wget -y
cd /home/ubuntu
wget https://aws-codedeploy-<region>.s3.<region>.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
sudo service codedeploy-agent status
(Replace <region> with your AWS region.)
✅ Make sure the agent is running.
Step 5: Create Deployment Group
Go to CodeDeploy → Your Application → Create Deployment Group.
Select the IAM Role created for CodeDeploy.
Choose the EC2 instance by selecting tags (
Name = simple-app).Disable the Load Balancer (not needed for this demo).
Create the group.



Step 6: Create Deployment
In your application, click Create Deployment.
Provide the GitHub commit ID you want to deploy.
Confirm and create.



On your EC2 instance:
sudo apt install docker.io -y
(For containerized apps, Docker must be installed.)
Deployment will now run, and you’ll see it progress in the CodeDeploy Console.

Output:

Step 7: Integrate CodeDeploy with CodePipeline
Now let’s complete the pipeline!
- Go to CodePipeline → Your Pipeline → Edit.

- Click Add Stage → name it
Deploy.


Add Action Group → choose CodeDeploy as the action provider.

Link it to the application & deployment group you created earlier.
Save.
✅ From now on, every commit → triggers CodePipeline → runs CodeBuild (CI) → then CodeDeploy (CD).
Now tadaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
You are all set here we gooooooooooooooooooooooo,
Output:

Your application is automatically deployed to EC2 whenever a commit is pushed.
The full AWS CI/CD pipeline is now working end-to-end:
GitHub → CodePipeline → CodeBuild → CodeDeploy → EC2.
Hope you like it :)



