Install code deploy-agent in aws ubuntu instance

Create a s3 bucket in a certain region and replace aws-codedeploy to the name of the bucket you created. Replace us-east-1 with the name of the region of your ec2 instance and s3 bucket. You can run the command as a bash script or manually in ubuntu instance terminal. ANY OF THE BELOW COMMAND WOULD WORK.

===============================FIRST COMMAND=============================
#!/bin/bash
# This installs the CodeDeploy agent and its prerequisites on Ubuntu 22.04.

sudo apt-get update
sudo apt-get install jq ruby-full ruby-webrick wget -y

SOURCE="https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/releases/"
DEBFILE=$(curl -s https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/LATEST_VERSION| jq .deb -r| sed -e 's|releases/||')
DEBNAME=$(echo $DEBFILE | sed -e 's|.deb||')

cd /tmp
wget $SOURCE$DEBFILE
mkdir $DEBNAME
dpkg-deb -R $DEBFILE $DEBNAME
sed 's/Depends:.*/Depends:ruby3.0/' -i ./$DEBNAME/DEBIAN/control
dpkg-deb -b $DEBNAME/
sudo dpkg -i $DEBFILE
systemctl list-units --type=service | grep codedeploy
sudo service codedeploy-agent status
==================SECOND COMMAND=========================================
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

sudo systemctl list-units --type=service | grep codedeploy

sudo service codedeploy-agent status