Table of contents
- Day 52: Your CI/CD pipeline on AWS
- Part 3 π β
- Task-01 :
- Read about Appspec.yaml file for CodeDeploy.
- Create a Ec2 role first--->
- Create application--->
- You have to set up a CodeDeploy agent to deploy code on EC2.
- Add appspec.yaml file to CodeCommit Repository and complete the deployment process.
- Make sure your artifact is created inside the S3 bucket.
- Deploy index.html file on EC2 machine using nginx.
- Day 52 task is complete!
Day 52: Your CI/CD pipeline on AWS
Part 3 π β
On your journey of making a CI/CD pipeline on AWS with these tools, you completed AWS CodeCommit & CodeBuild.
What is CodeDeploy?
AWS CodeDeploy is a deployment service that automates application deployments to Amazon EC2 instances, on-premises instances, serverless Lambda functions, or Amazon ECS services.
CodeDeploy can deploy application content that runs on a server and is stored in Amazon S3 buckets, GitHub repositories, or Bitbucket repositories. CodeDeploy can also deploy a serverless Lambda function. You do not need to make changes to your existing code before you can use CodeDeploy.
Task-01 :
Read about Appspec.yaml file for CodeDeploy.
Create a Ec2 role first--->
Create application--->
https://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html
You have to set up a CodeDeploy agent to deploy code on EC2.
To deploy your app to EC2, CodeDeploy needs an agent which deploys the code on your EC2.
Create a shell script with the below contents and run it
#!/bin/bash
# This installs the CodeDeploy agent and its prerequisites on Ubuntu 22.04.
sudo apt-get update
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
systemctl list-units --type=service | grep codedeploy
sudo service codedeploy-agent status
Add appspec.yaml file to CodeCommit Repository and complete the deployment process.
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html/
hooks:
AfterInstall:
- location: scripts/install_nginx.sh
timeout: 300
runas: root
ApplicationStart:
- location: scripts/start_nginx.sh
timeout: 300
runas: root
#install_nginx.sh
#!/bin/bash
sudo apt-get update
sudo apt-get install -y nginx
#start_nginx.sh
#!/bin/bash
sudo service nginx start
Make sure your artifact is created inside the S3 bucket.
Deploy index.html file on EC2 machine using nginx.
Happy Learning :)
Day 52 task is complete!
90DaysOfDevOps Tasksπ