Day 51 - CI/CD pipeline on AWS(Part 2)

Day 51 - CI/CD pipeline on AWS(Part 2)

Day 51 of 90daysofdevops

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 1

Read about the Buildspec file for Codebuild.

The buildspec.yml file is used in AWS CodeBuild to define the build specification for your project. It is a YAML file that specifies the steps and commands to be executed during the build process.

Create a simple index.html file in CodeCommit Repository.

You have to build the index.html using the nginx server.

We saw in yesterday's task, we have created a repository in AWS CodeCommit and written an index.html file and committed it.

Task 2

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

  • Create a buildspec.yml to build the file using an Nginx server.

    Here's what each step of the build does:

    • version: 0.2 specifies the version of the Buildspec syntax we're using.

    • phases: contains the build phases for our project.

    • install: Installs nginx on the build environment using the apt-get package manager.

    • build: Copies the index.html file to the default web root directory for nginx.

    • post_build: Performs any additional configuration for nginx, if necessary.

    • artifacts: Specifies the location of the index.html file to be included in the build artifact.

  • Move the file to the staging area and commit the file and push the committed file to the CodeCommit repository.

  • Verify the file in the remote repository along with the content.

  • Now, navigate to the CodeBuild section of AWS and click on 'Create build project'.

  • Enter the project name and description.

  • In the source section, select source provider AWS CodeCommit, select Repository that you created earlier and select branch master.

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

  • Click on the "Create build project" to create a project.

  • Build Project is created. Click the "Start build" button to start a new build.

  • All build phases are completed.

  • To add artifacts to a CodeBuild project and store them in an S3 bucket click on 'edit' and select 'Artifacts'.

  • First, create an S3 bucket.

  • The bucket is created successfully.

  • In Artifacts, select type Amazon S3 and select the bucket name that we created in the above step and Click on 'Update artifacts'.

  • After updating artifacts, click the "Start build" button again to start a new build. It succeeded.

  • Navigate to the S3 bucket and you can see the build.

  • Verify the build file and click the open URL to open the web app.

  • Click on 'open' and we can see the web app.

Thank you for reading!!
~Shreya Gupta

Great initiative by the #trainwithshubham community. Thank you Shubham Londhe

#devops #90daysofdevops #aws #iam #awsprojects #cicdpipelineonaws