CI/CD pipeline on AWS - Part 2 πŸš€ ☁

Β·

3 min read

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

  1. Read about the Buildspec file for Codebuild.

    A Buildspec file is a YAML file that provides AWS CodeBuild with the information it needs to build and package your source code. It contains a set of build commands and related settings that CodeBuild uses to execute the build. Without a build spec, CodeBuild cannot successfully convert your build input into build output or locate the build output artifact in the build environment to upload to your output bucket.

    The buildspec file contains the following sections:

    • version: This section specifies the version of the build specification schema that your build uses.

    • phases: This section specifies the build phases and the commands to be executed in each phase.

    • artifacts: This section specifies the output of the build, such as compiled binaries or packaged code, and where to store them.

    • cache: This section specifies the directories that should be cached to speed up the build process.

  2. Create a simple index.html file in CodeCommit Repository.

    Create a repository with a description as shown below.

    Create a user having CodeCommit permissions.

    Then select the security credentials in the user to generate HTTPS Git credentials for AWS CodeCommit.

    Make sure to download these credentials for further usage.

    Clone the HTTP URL of our repository as shown below.

    Open the VS code and git clone repository in this manner.

    Choose the folder where this clone repo will be placed in the local system. Then fill up the credentials in the Git Credential Manager window.

    Create an index.html file and put some sample code in it. Then commit it with the help of git commands.

    This committed file will then be pushed back to the CodeCommit repository.

    Here we can view our index file uploaded to our CodeCommit repo successfully.

  3. You have to build the index.html using the Nginx server.

    Go to CodeBuild in AWS and select Build projects on the left side list. Then click on Create build project button.

    Provide the source provider as AWS CodeCommit, repository name with the branch.

    Provide the environment details. Choose Ubuntu as Operating System & attach a new service role.

    The next step is adding Buildspec which is very important.

Task-02

  • Add the "buildspec.yml" file to CodeCommit Repository and complete the build process.

    Go to VS code and make a Buildspec file named buildspec.yml. Add configuration in this file to install the Nginx server as shown below and save it.

    Then git add and git commit these changes in the local system as well.

    Afterwards, this committed code will be pushed back to its origin i.e. CodeCommit repo master branch.

    Here we can view the Buildspec file in our repository.

    Come to the step where we left before in Task-01. Scroll down and click on Create build project button.

    Thus the project will be created successfully.

    The project will get start building by clicking on Start build button and it will be succeeded in this manner after some time.

That's all guys. Hope it will help you as well!

Reference is here: click here Video.


Thanks for reading the articles.

Keep motivated and Keep on hustling.

Peace out!!

Β