Day 51: CI/CD pipeline on AWS - Part 2

Hello, I am Akshay Phadke I have 10 Yrs of Experience in various Technologies. Currently, I am learning a few DevOps tools. I am working on Microsoft Technologies and AWS
What is CodeBuild?
AWS CodeBuild is a fully managed build service in the cloud. CodeBuild compiles your source code, runs unit tests, and produces artifacts that are ready to deploy. CodeBuild eliminates the need to provision, manage, and scale your own build servers.
Task-01 :
Read about Buildspec file for Codebuild.
A Buildspec file is a YAML file that defines the build process for your CodeBuild project. It contains a series of commands that CodeBuild will execute to build and package your application.
Create a simple index.html file in CodeCommit Repository.
you have to build the index.html using nginx server
Login to your AWS account by using valid credentials. Search CodeCommit from the search box and click on it. Click on Create repository. Enter mandatory details like the Repository name and Create a code commit repository.

Open VS Code or you can clone the repository by using HTTPS

Save the file and commit the changes to the repository using the git add and git commit commands.
git add <file-name>

git commit -m "commit message"

Push the changes to the repository using the git push command.
git push origin master

You have a simple index.html file in your CodeCommit repository

Task-02 :
Let's create a buildspec.yml file in our repository for our index.html file.
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
- Create
vim buildspec.ymla file in your repository.

- Now we will push this file to our repository.
git add .
git commit -m "Added buildspec.yml file"

git push origin master

- Now let's create a
CodeBuildproject inAWS Console.
- Step-01:
Create a CodeBuild Project.

- Step-02:
Give a nameto yourCodeBuild Project.

- Step-03:
Select your source providerandrepository.


- Step-04:
Select your environmentandoperating system.

Thus we have created our
CodeBuild Project.Now we will
start the buildso click onStart Build.

Once you start the build wait for it to be completed

Now we will create an AWS S3 bucket to add our build artifacts.
Step-01: Go to AWS S3 and create a bucket.

Step-02: Give a name to your bucket and create it.

- Thus we have created our
S3 bucket.

Now go to CodeBuild and edit your CodeBuild Project and edit artifacts.
- Step-01: Go to
CodeBuildandedityourCodeBuild Projectandedit artifacts.

- Step-02:
SelectyourS3 bucketandgive a nameto yourbuild artifacts.

Step-03:
Saveyourchangesandstart the buildagain so that theartifactsareuploadedto yourS3 bucket.
- Step-04:
Waituntil thebuild is finishedand after this checkbuild is finishedgo to yourS3 bucketandcheckif theartifactsareuploadedor not.

- Step-05: Now go inside your
artifactsand then /var/www/html/ and check if theindex.htmlthe file is present or not.

- Step-06: Click on the open button and check if the
index.htmlthe file is present or not.




