On your journey of making a CI/CD pipeline on AWS with these tools, we 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 build servers.
🔶 Task-01: Buildspec file for Codebuild.
Read about the Buildspec file for Codebuild.
Create a simple index.html file in the CodeCommit Repository.
Log in to AWS Management Console and go to CodeCommit.
Create or select an existing secure repository to store and share your code.
Clone the Repository
Open the terminal and navigate to the directory where you want to clone the CodeCommit repository.
Run the following command, replacing
<repository-url>with the URL of your CodeCommit repository:
git clone https://<repository-url>
When prompted, enter the Git credentials (username and password) you generated in the IAM user. This will authenticate your local Git client with CodeCommit.
You have to build the index.html using the nginx server.
🔶 Task-02: Add the buildspec.yaml file to CodeCommit Repository and complete the build process.
version: 0.2 phases: pre_build: commands: - echo "Installing NGINX..." - sudo apt-get update - sudo apt-get -y install nginx - echo "NGINX installed." build: commands: - echo "build started on 'date'" - cp index.hmtl /var/www/html post_build: commands: - echo "Configuring NGINX.." artifacts: files: - '**/*'
gitcommand to push the
buildspec.yamlfile to your CodeCommit repository:
git add . git commit -m "Adding index.hmt and buildspec.yaml" git push origin master
Set up CodeBuild:
In the AWS Management Console, navigate to AWS CodeBuild.
Create a new build project.
Configure your source provider (CodeCommit).
Select source provider AWS CodeCommit, Repository and Branch master.
Choose the build environment, and specify the buildspec file location (
buildspec.yamlin the root directory), and set environment variables as needed.
Create the build project.
Start the build.
Check the logs and phases steps:
Now Create an S3 bucket.
Now Add Artifacts to a Codebuild and store them in the S3 bucket.
Now Start building again.
Now go to your S3 bucket and check for the index.html file under your bucket object.
Now Select the open button to open the html file in the browser.
For more details watch this video.
Happy Learning :)
Stay in the loop with my latest insights and articles on cloud ☁️ and DevOps ♾️ by following me on Hashnode, LinkedIn (https://www.linkedin.com/in/chandreshpatle28/), and GitHub (https://github.com/Chandreshpatle28).
Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.
Did you find this article valuable?
Support CHANDRESH PATLE by becoming a sponsor. Any amount is appreciated!