Skip to main content

Command Palette

Search for a command to run...

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

Updated
3 min read
Day 51: CI/CD pipeline on AWS - Part 2
A

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.yml a 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 CodeBuild project in AWS Console.
  • Step-01: Create a CodeBuild Project.

  • Step-02: Give a name to your CodeBuild Project.

  • Step-03: Select your source provider and repository.

  • Step-04: Select your environment and operating system.

  • Thus we have created our CodeBuild Project.

  • Now we will start the build so click on Start 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 CodeBuild and edit your CodeBuild Project and edit artifacts.

  • Step-02: Select your S3 bucket and give a name to your build artifacts.

  • Step-03: Save your changes and start the build again so that the artifacts are uploaded to your S3 bucket.

  • Step-04: Wait until the build is finished and after this check build is finished go to your S3 bucket and check if the artifacts are uploaded or not.

  • Step-05: Now go inside your artifacts and then /var/www/html/ and check if the index.html the file is present or not.

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

More from this blog

Untitled Publication

80 posts