Installing AWS CodeDeploy Agent on Debian : A Step-by-Step Guide

Introduction to AWS CodeDeploy

AWS CodeDeploy is a powerful deployment service offered by Amazon Web Services that automates the deployment of your applications to various compute services such as Amazon EC2, AWS Fargate, and AWS Lambda. It's a boon for developers looking to automate their deployment process, ensuring consistent and reliable software deployments.

Preparing Your Ubuntu Server

Before diving into the installation, it's crucial to prepare your Ubuntu server. Start by updating your instance to ensure all packages are current:

sudo apt update

sudo apt upgrade


Installing Ruby and Wget

AWS CodeDeploy requires Ruby. So, the next step is to install Ruby and Wget (a utility for downloading files from the web):


sudo apt install ruby wget


Downloading and Installing the AWS CodeDeploy Agent

With Ruby and Wget installed, you can proceed to download the CodeDeploy agent:

wget https://aws-codedeploy-eu-west-1.s3.eu-west-1.amazonaws.com/latest/install

chmod +x ./install

sudo ./install auto


This series of commands downloads the installation script, makes it executable, and runs it. The script is quite intelligent; it automatically detects the package manager and installs any necessary dependencies, such as `gdebi` in our case.


What Happens During Installation?

The installation script performs several critical steps:

1.Dependency Management: It checks for `apt-get` and installs `gdebi` if it's not available. `gdebi` is crucial for handling local `.deb` files and their dependencies.

2.Region and Domain Verification: The script smartly checks for AWS region and domain, ensuring it fetches the right version of the CodeDeploy agent.

3.Agent Download and Installation: The correct `codedeploy-agent` package is downloaded and installed. In our specific instance, it was `codedeploy-agent_1.6.0-49_all.deb`.

4.Service Initialization: Post-installation, the CodeDeploy agent service is enabled to start automatically with the system.


Post-Installation Checks

After the installation, it's always good practice to perform some checks:

Check the Agent Status: Use `sudo service codedeploy-agent status` to ensure the agent is running properly.

Review Logs: AWS CodeDeploy agent logs, located at `/var/log/aws/codedeploy-agent/`, are invaluable for troubleshooting or confirming proper operation.

Final Thoughts

Installing the AWS CodeDeploy agent on Ubuntu 22.04.3 LTS is a straightforward process, but it's vital to follow each step carefully. This ensures a smooth deployment experience, enabling developers and operations teams to focus on what they do best – building and deploying great software.

And remember, always ensure your EC2 instance has the necessary IAM roles for AWS CodeDeploy. Happy deploying! 🚀