Skip to main content

Command Palette

Search for a command to run...

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

Published
3 min read
Part 3: Continuous Deployment with AWS CodeDeploy (Integrating with CodePipeline)
S

🌱 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:

  1. Launch an EC2 instance.

  2. Add a tag (for CodeDeploy to identify it):

    • Key: Name

    • Value: simple-app

Step 3: Configure IAM Roles

We need two roles:

  • Role for EC2 → To talk to CodeDeploy

    • Attach AmazonEC2RoleforAWSCodeDeploy (or AmazonEC2FullAccess for demo).
  • 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

  1. Go to CodeDeploy → Your Application → Create Deployment Group.

  2. Select the IAM Role created for CodeDeploy.

  3. Choose the EC2 instance by selecting tags (Name = simple-app).

  4. Disable the Load Balancer (not needed for this demo).

  5. Create the group.

Step 6: Create Deployment

  1. In your application, click Create Deployment.

  2. Provide the GitHub commit ID you want to deploy.

  3. 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!

  1. Go to CodePipeline → Your Pipeline → Edit.

  1. Click Add Stage → name it Deploy.

  1. Add Action Group → choose CodeDeploy as the action provider.

  2. Link it to the application & deployment group you created earlier.

  3. 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 :)