Unleashing CodeBuild Magic: A Deep Dive into AWS Development | 30 Days of AWS — Day 13" 🚀💻
Introduction:
🚀 Welcome to Day 13 of our exhilarating 30 Days of AWS series! 🌐 Today, we’re strapping in for a deep dive into the heart of AWS development — the CodeBuild service. 🛠️ As we continue our journey through the cloud, we’ll unravel the mysteries behind this powerful tool and guide you on harnessing its potential. So, grab your virtual hard hats and join us on this exciting exploration of AWS CodeBuild! 💻✨
What is Code Build?
AWS CodeBuild is a fully managed build service that compiles source code, runs tests, and produces software packages that are ready to deploy. With CodeBuild, you don’t need to worry about provisioning and managing your own build infrastructure. You simply provide your build project’s source code and build settings, and CodeBuild handles the rest.
For example, if you have a web application that you want to deploy, you can use CodeBuild to compile your source code, run unit tests, and produce a deployable package. You can also use CodeBuild to build Docker images, run static code analysis, and more. CodeBuild integrates with other AWS services like CodePipeline, so you can easily automate your entire software release process.
What is the Buildspec file for Codebuild?
The Buildspec file is a configuration file used by AWS CodeBuild to define how to build and deploy your application or software project. It is written in YAML or JSON format and contains a series of build commands, environment variables, settings, and artefacts that CodeBuild will use during the build process.
Let’s Build the code step by step:
Step:1
Go to the AWS management Console and Navigate to the CodeBuild Service
You will see this type of Interface. Click on the Create Project.
- Write your project name here I give demo-build
- Now the main part comes that what your source form your code will come and code build service builds that code.
- Here I am selecting source as an AWS code Commit, if you do not know what is code commit then please visit my day 12 blog there I explained everything regarding the Code commit Service.
- After that select Repository for build code.
- So now what is a Reference Tag: A reference tag is nothing but the identification of your code here I am selecting the branch tag.
- In Environment Section we leave as it is
- Now In the operating System, we will select Ubuntu
- Runtime as a standard and Image we were selecting Latest and service role as the New service role.
- Now the main part comes in the picture:
- Already we have discussed what is buildspec file.
- So we will add the buildspec file in our code commit repo
- Now in our repository, there are two files one is index.html and the second is buildspec.yml file
index.html
My Website
Welcome to my website
This is a simple website hosted on AWS CodeCommit.
buildspec.yml
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
- Basically, we are hosting one index.html file on the nginx server.
- If you want to learn how to write the buildspec file then you can visit to the AWS Code Build documentation
- https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
- You can visit the above link.
- For the demo purpose here we do not selecting artifacts to be generated
- Now click on Create Build Project
- Your Code Build Project Successfully Created.
- Congrats on your first build success.
- Now we will store the Artifacts:
- For that Go to the code build and select your code build project.
- Click On the edit option
- And after that Click on Artifacts
- Now we will select Artifact type as S3
- Now we have to choose s3 bucket, but we do not created any bucket for code build let’s first create the Bucket first.
- Go to the Management Console and Navigate to the S3 service.
- Click on the Create Bucket.
- Give the name to your bucket.
- Click on the Create Bucket.
- Navigate to the project build, click on edit and select artefact. Provide all the details and create artifact.
- We successfully Upload the artefacts to the S3 bucket.
- Let’s see
- Go to the S3 bucket and check the bucket that you recently created for the artefacts.
- We successfully got the Artifacts.
- Now click on the open button you will see your index file that is live now on the NGINX server.
That’s All from my side in today’s blog
If you like this blog then give one like and give one star
If you have any dought in this particular blog then let me know in the comment section.
GitHub Profile:
[PurushotamSharma - Overview
Purusing MCA from Charusat University. PurushotamSharma has 35 repositories available. Follow their code on GitHub.github.com](https://github.com/PurushotamSharma "github.com/PurushotamSharma")
Github Repo for this AWS Series:
[GitHub - PurushotamSharma/30-Days-of-AWS-Adventure-
Contribute to PurushotamSharma/30-Days-of-AWS-Adventure- development by creating an account on GitHub.github.com](https://github.com/PurushotamSharma/30-Days-of-AWS-Adventure- "github.com/PurushotamSharma/30-Days-of-AWS-..")
Happy Learning :::