Prepare the EC2 server
Install the CodeDeploy agent and confirm the server is ready to receive releases.
About 15 min · Verified 8 October 2026
CodeDeploy does not log in to your server. Instead a small agent program runs on it, asks CodeDeploy "is there a deployment for me?", downloads the bundle and runs your hook scripts. You install the agent once.
Run everything in this chapter on the EC2 instance: EC2Instancesshortlink-apiConnectSession Manager.
Install the agent#
Install the prerequisites#
sudo apt-get update
sudo apt-get install -y wgetDownload and run the installer for your Region#
The installer is served from a regional S3 bucket. The URL contains your Region twice.
cd /tmp
wget -O codedeploy-install https://aws-codedeploy-ap-south-1.s3.ap-south-1.amazonaws.com/latestv2/install
chmod +x ./codedeploy-install
sudo ./codedeploy-install autoThe installer complains about Ruby
Older agent versions needed Ruby. The latestv2 installer normally does not. If you see ruby: command not found, install it and run the installer again:
sudo apt-get install -y ruby-full
sudo ./codedeploy-install autoCheck that the agent is running#
sudo systemctl is-active codedeploy-agentactiveCheck what the hooks rely on#
The service and the env file exist#
systemctl is-enabled shortlink-api
sudo -u ubuntu test -r /etc/shortlink/shortlink.env && echo "env file readable by ubuntu"
test -d /opt/shortlink && echo "/opt/shortlink exists"
command -v nodeenabled, then env file readable by ubuntu, /opt/shortlink exists, and /usr/bin/node.If any of these fail, go back to the Install and start the API chapter in guide 1. The very first release would otherwise fail in BeforeInstall.
Found a mistake? Edit this page on GitHub.