AWS CodeBuild: A Fully Managed Build Tool

February 16, 2017 | Comments(3) |

Integrate Code, Build Artifact, Manage release. If you know the pain of these processes you might need to look at AWS CodeBuild. Maintaining a project developed by many team members concurrently which is composed of different functions, environment, and languages, AWS CodeBuild is here to help you.

AWS CodeBuild is a fully managed service that compiles your source code and gives you a software package which you can directly deploy into your servers. Instead of setting up and scaling your own build server fleet, you can use CodeBuild to streamline your development process. AWS CodeBuild is elastic, scalable, and easy to use. For each build, it launches a fresh, Isolated container-based environment and terminates it after the build process ends. You can also use CodeBuild as AWS CodePipeline Build Provider.

Let’s look at the major Terminologies of AWS CodeBuild.
• Source Repository – Location of your source code.
• Build Environment – Your runtime environment.
• IAM Role – Grants CodeBuild permission to access to specific AWS services and resources.
• Build Spec – Build commands.
• Compute Type – Amount of memory and compute power required.

AWS CodeBuild uses Docker containers to build your code depending on your environment. You can use build environments provided by AWS or existing Docker images from Docker hub or Elastic Container Registry. Currently AWS provides build environments for Java, Android, Ruby, Go, Node.js, Python, and Docker (to build Docker images). All your command line output is streamed into AWS management console during the build process. Let’s go through the build process.

  • CodeBuild fetches code from the Source repository. It could be S3 Bucket, GitHub Repository, or AWS CodeCommit Repository.
  •  Runs the commands in the build spec. You can have a buildspec.yml file in the source code root directory or you can explicitly write your build commands. The buildspec contains four phases. Install, pre-build, build and post-build.

-> Install – Install packages in the build environment if any.
-> Pre-build – Commands that should run before build if any.
-> Build – Commands to build the artifact.
-> Post-build – Commands to run after the build if any.

  • Uploads the generated artifact to S3 with optional KMS encryption.

Here is an example for your buildspec.yml


Now, let us see how to build your first project in AWS CodeBuild. I’m going to show you how to build a maven project here. I have my maven code zipped and pushed into S3 Bucket.

Step1: Go to AWS CodeBuild console and create a project.


Step2: Give a project name and a description.

456Step3: Select source provider as S3, select your bucket from the drop-down list and provide your filename.

Step4: Configure your environment to build. Let us use an image managed by AWS.
Select Runtime as Java, and use Java: openjdk-8 as the version. Under Build command gives as mvn clean package.

789Step5: Describe where you need your artifacts to get saved.

10Step6: Select the Service role for your project and click on continue.

11Step7: Click on Save and build to start to build.

img7Step8: This will build your project. To see your build logs from the console.

open the project and select the latest build. Once the project is built successfully you will see your status SUCCEEDED.


You pay only for the resources you use. You charged for the compute resources you use per minute.

Please write us at for any queries.

3 Responses to “AWS CodeBuild: A Fully Managed Build Tool”

  1. CarlesCF

    Hi, I am having problems compiling an Android project because of the SDK license acceptance. When gradle assemble command is running it abruptly ends with a message: “You have not accepted the license agreements of the following SDK components” And then several packages (since I have been changing de SDK version and Android Build Tools version). Is there a way to accept licenses???


Leave a Reply