Day 51: Your CI/CD pipeline on AWS - Part 2 ๐Ÿš€ โ˜

Day 51: Your CI/CD pipeline on AWS - Part 2 ๐Ÿš€ โ˜

ยท

3 min read

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.

CodeBuild downloads the source code into the build environment and then uses the build specification (buildspec), as defined in the build project or included directly in the source code. A buildspec file is a collection of build commands and related settings, in YAML format, that CodeBuild uses to run a build.

  • create a simple index.html file in the CodeCommit Repository

We already have a repository which we created in the Day50 task. Add a file index.html in the Day50 repository.

Steps -

  • Go to the repository and create a new file or, create a file on the system and push it to the CodeCommit repository.

  • Commit the changes -

  • you have to build the index.html using the nginx server

Task-02 :

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

Steps -

  • Create a buildspec.yml file for the build process

  • We have three phases in the buildspec.yml file -

    • Install - This phase includes commands to install NGINX. It updates the package list and installs NGINX on the build environment.

    • Build - This phase logs the start time and then copies an index.html file to the NGINX web server directory.

    • Post_build - This phase is currently empty but could be used for additional post-build tasks. For now, we are just giving echo command to print.

Artifacts: It specifies the files that should be saved as build artifacts. In this case, it includes the index.html file located in the NGINX web server directory.

Version: This specifies the version of the buildspec file format, which is 0.2 in this case.

  • Go to CodeBuild > Create build project

  • Give the project name and description of the project.

  • Give the source as AWS CodeCOmmit repository and the branch where we have our index.html file.

  • Select the below options for Environment, we are selecting OS as Ubuntu and the latest image version.

  • Select other options as default and create the build project.

  • Start the build once the build is created.

  • Monitor the phase status under phase details, the build is successful.

  • Validate the output from the logs if all phases were performed correctly.

Thank you :)

ย