CodeDeploy Agent Role in EC2 CI/CD Deployment
This blog post explains about how the code deploy agent plays a crucial role in the deployments on the EC2 servers.
CodeDeploy Agent is a software package that is installed on the target ec2 server. CodeDeploy Agent refers the appspec.yml and it execute operations based on the steps defined in the appspec.yml. Codedeploy agent communicates using HTTPS protocol at port 443.
You can install the code deploy agent using two methods:-
CodeDeploy installation using system manager
CodeDeploy installation using command line
Below is the steps to install the code deploy agent using the command line
sudo yum update
sudo yum install ruby
sudo yum install wget
cd /home/ec2-user
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
You can confirm the installation of code deploy agent by using systemctl status codedeploy-agent.service.
By default the code deploy agent stores the artifacts, revision, logs in the /opt/codedeploy-agent/deployment-root path.
/opt/codedeploy-agent/deployment-root directory contains:-
Deployment-Group ID :- It is a unique id which is different for each deployment group e.g a7c456d9-c2ge-3b5c. Inside the deployment group id there is deployment id.
Deployment ID:- It is a unique string which is generated each time the code deploy is executed. It further contains the bundle.tar, deployment-archive & logs. By default the latest 5 deployment ID's are stored inside the deployment group ID folder.
To change the default configuration you can edit the file under the path /etc/codedeploy-agent/conf/codedeployagent.yml.
You can change the max_revision parameter inside the file if you want to change the default number of deployment ID's stored.bundle.tar:- It is a tar file which contains the latest build artifacts in a compressed form. You can not decompress it directly using tar command. First you need to rename it from bundle.tar to bundle.zip. After that use the unzip command to get the content inside the compressed package.
deployment-archive:- This section contains the last deployment execution artifacts. This folder work as a backup.
logs:- This folder contains the scripts.log file which contains the logs of current deployment execution. It gets updated after every deployment execution.
deployment-logs : - This folders contains the file codedeploy-agent-deployments.log which have the logs of code deploy agent execution.
Conclusion :-
In summary, the CodeDeploy Agent facilitates seamless deployment processes on EC2 servers by interpreting appspec.yml, executing specified steps, and managing artifacts and logs in a structured directory hierarchy. Users can customize configurations to suit their deployment requirements.