AWS CI/CD DevOps Project
Architecture Diagram
First, we need to Create Git Repository using a code commit
Click to Create Repository and enter the repo name and description and create the repo, the output will show as below.
Users can access the code commit needed to create one IAM and assign AWSCodeCommitPowerUser policy and provide security credentials to the user.
Clone your created Repo on your local system using VS code or any other git tools and enter your secret credentials just as we created before.
Create one file and push it to your Test Repo, below are the commands
git clone <gitURL>
git add .
git commit -m <message>
git push origin master
How to Build the project in Code build, click on create build project.
Enter details in required fields as name and description
Select the source code provider, we select the code commit and select the project repo and branch as show below. If you want to build a specific commit then select commit ID other wise blank.
For the build process we need to select Environment to build your code.
Also, we need a one-service role to execute the build process.
We need one build spec file to build our code, the file name is buildspec.yml. this file is put in your code commit.
buildspec.yml
version: 0.2
phases:
install:
commands:
- echo Installing NGINX
- sudo apt-get update
- sudo apt-get install nginx -y
build:
commands:
- echo build started on 'date'
- cp index.html /var/www/html/
post_build:
commands:
- echo Configuring NGINX
artifacts:
files:
- /var/www/html/index.html or ‘**/*’ for all the files
We can store artefacts anywhere we will use s3 for that, save all the settings, and build the project.
As we see build is failed due to buildspec.yml not found so we will commit buildspec.yum file code and build again.
So we have successfully built our code and artefact store in the s3 bucket.
Run the below command in the ec2 instance to install the code deploy the agent
sudo yum update
sudo yum install ruby
sudo yum install wget
wget https://{bucket-name}.s3.amazonaws.com/latest/install
use below URL for bucket name and region
https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install-linux.html
chmod +x ./install
sudo ./install auto
sudo service codedeploy-agent status
create one IAM role for the ec2 instance to connect with code deployment and s3 bucket and attached to the ec2 instance.
Create deployment for deploying code to ec2 instance as shown below
To create CI/CD pipeline below setting needed
That's all our AWS CICD pipeline !!
Reference Code:-https://github.com/rahulwath/AWS-CICD-DEVOPS
Thanks for reading the article.
Hope it will help you.
Keep learning and hustling.
Stay tuned for the next project.
Subscribe to my newsletter
Read articles from Rahul wath directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Rahul wath
Rahul wath
An experienced DevOps Engineer understands the integration of operations and development in order to deliver code to customers quickly. Has Cloud and monitoring process experience, as well as DevOps development in Windows, Mac, and Linux systems.