On your journey of making a CI/CD pipeline on AWS with these tools, you completed AWS CodeCommit.
Next few days you'll learn these tools/services:
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: Building an index.html File with Nginx Server Using CodeBuild
1 -> Read about Buildspec file for Codebuild.
The buildspec.yml file allows you to define and configure the build process for your CodeBuild project. It provides an easy way to specify build instructions in a declarative YAML format.
2 -> Create a simple index.html file in CodeCommit Repository.
Navigate to the CodeCommit service.
Select the repository where you want to add the
- Click on "Create file"
- Enter the name and add the following content.
<html> <head> <title>My Website</title> </head> <body> <h1>Welcome to my website</h1> <p>This is a simple website hosted on AWS CodeCommit.</p> </body> </html>
- Now, Click on "Commit Changes" to save the changes.
- Let's clone the repository to your instance and verify the files.
Task 2: Add buildspec.yaml file to CodeCommit Repository and complete the build process.
- Create a buildspec.yaml file.
version: 0.2 phases: install: commands: - echo Installing NGINX - echo apt-get install 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
- Commit the Buildspec.yml file to the CodeCommit repository.
- Push the file to the CodeCommit repository.
- Now, navigate to the CodeBuild section of AWS and build project.
- Click on "Create build project" and give the details.
- Select Use build spec file in Buildspec section and click on "Create build project"
- Project created, now click on "Start build"
- Code build is successfully completed.
- You can store the build details in the artifactory.
- Before that, create an S3 bucket. Navigate to the S3 bucket in the AWS console and provide the bucket name and create the bucket.
- Click on "Create bucket"
- Navigate to the project build, click on edit and select artefact. Provide all the details and create artifact.
- Click on "Update artifacts"
- Now, if you rebuild the project you can see the UPLOAD_ARTIFACTS section.
- Now, Navigate to the S3 bucket and you can see the build.
- Click open URL to open the demo-app
- Here is an output of index.html file.
"Thank you for enjoying my DevOps blog! Your positive response fuels my passion to dive deeper into technology and innovation.
Stay tuned for more captivating DevOps articles, where we'll explore this dynamic field together. Follow me on Hashnode and connect on LinkedIn (https://www.linkedin.com/in/som-shanker-pandey/) for the latest updates and discussions.
Did you find this article valuable?
Support Som Pandey by becoming a sponsor. Any amount is appreciated!