Explore how Jenkins versions have shaped modern CI/CD practices. This comprehensive guide traces the …
Create CodeBuild with Custom Image in AWS | Personal Blog Create CodeBuild with Custom Image in AWS | Personal Blog

Summary
How did it start?
“Hey, I need you to create a CodeBuild project for me.”
I turned around from my computer screen to see my boss walking towards me. We had just moved into our new office and everyone was still getting used to the change. It had only been two weeks, but it felt like forever.
“Sure thing,” I said as I got up from my chair. “What do you need?”
He handed me a sheet of paper with all the details on it. “We want to create a custom image for CodeBuild that will include all of our company’s dependencies.”
I nodded as I started to understand what he was asking. “Do you have any existing scripts or code we can use as a template?”
He shook his head. “No, we need something completely new.”
So I started working on the project to create the Build Project with the custom image. The software which we were using was working over the golang.
Today, here I am going to create a build project with a custom image of golang’s latest version. Because default runtime environment images for the code build support the limited versions of the golang upto 1.16 (by the writing of this Article). I want to use the latest golang’s version.
Expand your knowledge with Advantages of golang for AWS Lambda.
Setup
Create a private repository in the AWS ECR. Learn More
You need to run Docker Login, so we can push to the ECR
Deepen your understanding in Setup CodeBuild with bitbucket private repo
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com
Custom Image
Download the golang base image
Re Tag the image as per your Amazon Docker/Container Registery
Push to the repository
Explore this further in Advanced String Operations in Bash: Building Custom Functions
docker pull golang docker tag golang:latest <account-id>.dkr.ecr.us-east-1.amazonaws.com/<your-ecr-repo>:latest docker push 983430949435.dkr.ecr.us-east-1.amazonaws.com/<your-ecr-repo>:latest
Code Build
- Create a Code Build Project. Learn More
- You will need to make sure to use the Custom image for Environment Image and Project Service Role for the Image Pull Credentials
s3.amazonaws.com/images-netlify-karandeep-singh/karandeepsingh/CodeBuild_AWS_Developer_tools.png" alt="You will need to make sure to use the Custom image for Environment Image and Project Service Role for the Image Pull Credentials" title="You will need to make sure to use the Custom image for Environment Image and Project Service Role for the Image Pull Credentials">
s3.amazonaws.com/images-netlify-karandeep-singh/karandeepsingh/create_codebuild_with_custom_image.png" alt="You will need to make sure to use the Custom image for Environment Image and Project Service Role for the Image Pull Credentials" title="You will need to make sure to use the Custom image for Environment Image and Project Service Role for the Image Pull Credentials">
Discover related concepts in Mastering BuildSpec.yml: Your Complete Guide to AWS CodeBuild Configuration
Test
Since you have created a project and attached the source code, I assume you already have an errorless buildspec.yaml ready in your code. Now you can start a build, and it will pass. If you want to learn how to build a gohugo serverless website framework, then you can read this.
Similar Articles
Related Content
More from devops
Learn essential Jenkins Versions strategies to optimize your CI/CD pipelines. This guide covers …
Master the Linux ls command with this comprehensive guide covering basic and advanced options, …
You Might Also Like
Learn how to design a Pokémon GO-like game on AWS with this comprehensive system design guide. We'll …
Explore essential AWS security features that protect your cloud infrastructure from threats. Learn …
Dive into the ultimate guide to mastering templating with `envsubst` and Jinja2. From Ansible to …