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

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

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 the Buildspec file for CodeBuild.

The build procedure for your CodeBuild project is specified in a Buildspec file, a YAML file. To build and bundle your program, CodeBuild will run a number of instructions from this file.

Create a simple index.html file in CodeCommit Repository.

you have to build the index.html using nginx server

Create a code commit repository

No alt text provided for this image

Copy clone HTTPS URL

No alt text provided for this image

Use the git clone command in git bash to copy the repository to your computer.

No alt text provided for this image

Create an index.html file inside the code commit repository.

No alt text provided for this image

With the git add and git commit commands, you can save the file and add the modifications to the repository.

git add <file-name>        
No alt text provided for this image
git commit -m "commit message"        
No alt text provided for this image

Using the git push command, add the modifications to the repository.

No alt text provided for this image

A straightforward index.html file can be found in your CodeCommit repository.

No alt text provided for this image
No alt text provided for this image

Task-02 :

Add buildspec.yaml file to CodeCommit Repository and complete the build process.

To build the file with a nginx server, create a Buildspec file.

No alt text provided for this image

Below are the functions of each build step:

  • The version of the Buildspec syntax we're using is stated as version: 0.2.
  • Phases: This lists the stages of construction for our project.
  • install: utilizes the apt-get package manager to install nginx on the built environment.
  • build Places a copy of the index.html file in the nginx default web root directory.
  • post build: If additional nginx settings are required, it is done.
  • Indicates where the index.html file should be included in the build artifact.

With the git add and git commit commands, you can save the file and add the modifications to the repository.

No alt text provided for this image
No alt text provided for this image

Push the changes to the code commit repository

No alt text provided for this image

You have two files in your CodeCommit repository: buildspec.yml and index.html.

No alt text provided for this image

Create a project:

Visit the service for CodeBuild. Choose "Create build project" from the menu.

No alt text provided for this image

Your build project's name, source provider (CodeCommit), repository, and branch should all be entered.

No alt text provided for this image

Choose AWS CodeCommit as the source provider in the source area, then choose the repository you previously created and branch master.

No alt text provided for this image

In the Environment section, choose the operating system, and runtime ad image.

No alt text provided for this image

Choose "Use a buildspec file" in the "Buildspec" section when creating a new service role.

No alt text provided for this image

Click "Create build project" to create your project.

No alt text provided for this image

The project is successfully created.

To begin a fresh build, click the "Start construction" button.

No alt text provided for this image

Verify the status of the successful build.

No alt text provided for this image

Each step of the phase was successful.

No alt text provided for this image

to include artifacts and store them in an S3 bucket as part of a CodeBuild project.

Choose "Artifacts" under "edit" after clicking.

No alt text provided for this image

First, create an S3 bucket.

No alt text provided for this image
No alt text provided for this image

the bucket is successfully created.

No alt text provided for this image

Choose the Amazon S3 type and the bucket name you created in the previous step under Artifacts.

No alt text provided for this image

Choose "Update artifacts."

To begin a new build after updating artifacts, click the "Start build" button once more.

No alt text provided for this image

The built-in S3 bucket location will receive the artifacts after the build is finished.

No alt text provided for this image

The path of the file, which is /var/www/html/index.html, is specified in the artifacts phase of the buildspec.yml file. You can verify that the s3 bucket has folders and an index.html file.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Click on 'index.html' file, below you can see the properties of the file.

Click on 'open' on the right-hand side.

No alt text provided for this image

Here is an output of index.html file.

No alt text provided for this image

Thank you for sticking with me; I hope you learned something. 🙌 🙌

Aprajita Gupta

Aspiring Devops Engineer || Linux | AWS | Jenkins |Github | Docker | Kubernetes | Terraform| Ansible

1y

Nice 🙂

Sunil Kumar

Senior Cloud Engineer - Nagarro | Google Cloud Certified {"CDI, ACE , PCA, PDE}|Cloud DevOps Specialist | 5x GCP , Azure Certified | Devops | Linux | Docker | Terraform | Jenkins CI/CD | Kubernetes

1y

Good going !! Vinay Kumar

Sayali Jadhav

DevOps Engineer at BH Mobile Pte Ltd || AWS || Linux || CICD || Jenkins || Git GitHub || Docker || Kubernetes || Terraform ||

1y

Great work Vinay Kumar

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics