Basic CI CD Setup Guide 1726141961
Basic CI CD Setup Guide 1726141961
By Tushar Gupta
Objective:
The goal is to set up a CI/CD pipeline that automates the deployment of a simple web
application to a server. The pipeline should trigger on code pushes to a repository and deploy
the application in a scalable manner. When load increases, the number of servers should
automatically scale up or down, ensuring that new servers have the latest code.
Tools Used:
1. AWS CodeDeploy
2. AWS Auto Scaling
3. AWS Load Balancing
4. AWS CodePipeline
5. AWS EC2
6. Git/Bitbucket
Step-by-Step Process
● In the User Data section, provide a script that automatically installs the CodeDeploy
agent when the instance is launched. This ensures that the CodeDeploy agent is set up
without manual intervention.
#!/bin/bash
sudo su
apt update
apt upgrade -y
apt install nginx -y
sudo apt update
sudo apt install ruby-full -y
sudo apt install wget
cd /home/ubuntu
wget https://aws-codedeploy-ap-south-1.s3.ap-south-1.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
● After configuring the above settings, create the EC2 launch template.
● Check the Load Balancer dashboard to ensure the Load Balancer is created and is in
the provisioning state. It will eventually transition to an active state.
CodeDeploy Setup
● Service: CodeDeploy
● Permissions: AWSCodeDeployRole
3. Create a Deployment Group
1. Create a Pipeline
● If your project does not require a build step (e.g., if it's just an HTML page), skip this
stage.
● Once the pipeline is set up, it will attempt to deploy the code. However, it will fail initially
if no EC2 instances are available. This is expected behavior.
Deploying the Application
● Terminate Instances: After testing, make sure to either terminate the instances
manually or reduce the Auto Scaling group size to 0. This will prevent unnecessary
charges.
Conclusion: By following the above steps, you can successfully set up a CI/CD pipeline that
deploys a web application to AWS. The pipeline is designed to scale automatically with load,
ensuring high availability and consistency in deployment.