Setting Up AWS CodeDeploy Agent on Ubuntu EC2

Setup an AWS CodeDeploy Agent in simple steps

Fri Feb 10, 2023

Its easy :)

I got many errors while doing this, so here's a blog for setting up things in an easy way

In order to deploy your app to EC2, CodeDeploy needs an agent which actually deploys the code on your EC2.

So let's set it up.

Create a shell script with the below contents and run it

#!/bin/bash 
# This installs the CodeDeploy agent and its prerequisites on Ubuntu 22.04.  
sudo apt-get update 
sudo apt-get install ruby-full ruby-webrick wget -y 
cd /tmp 
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/releases/codedeploy-agent_1.3.2-1902_all.deb 
mkdir codedeploy-agent_1.3.2-1902_ubuntu22 
dpkg-deb -R codedeploy-agent_1.3.2-1902_all.deb codedeploy-agent_1.3.2-1902_ubuntu22 
sed 's/Depends:.*/Depends:ruby3.0/' -i ./codedeploy-agent_1.3.2-1902_ubuntu22/DEBIAN/control 
dpkg-deb -b codedeploy-agent_1.3.2-1902_ubuntu22/ 
sudo dpkg -i codedeploy-agent_1.3.2-1902_ubuntu22.deb 
systemctl list-units --type=service | grep codedeploy 
sudo service codedeploy-agent status

Shubham Londhe
A California-based travel writer, lover of food, oceans, and nature.