Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

🎁 Get 20% Off - Christmas Big Sale on All Practice Exams, Video Courses, and eBooks!

AWS CodeBuild

AWS CodeBuild

Last updated on June 23, 2023

AWS CodeBuild Cheat Sheet

  • A fully managed continuous integration service that compiles source code, runs tests, and produces software packages that are ready to deploy.

Concepts

    • A build project defines how CodeBuild will run a build. It includes information such as where to get the source code, which build environment to use, the build commands to run, and where to store the build output.
    • A build environment is the combination of operating system, programming language runtime, and tools used by CodeBuild to run a build.
    • The build specification is a YAML file that lets you choose the commands to run at each phase of the build and other settings. Without a build spec, CodeBuild cannot successfully convert your build input into build output or locate the build output artifact in the build environment to upload to your output bucket.
      • If you include a build spec as part of the source code, by default, the build spec file must be named buildspec.yml and placed in the root of your source directory.
    • A collection of input files is called build input artifacts or build input and a deployable version of a source code is called build output artifact or build output.

Features

    • AWS CodeBuild runs your builds in preconfigured build environments that contain the operating system, programming language runtime, and build tools (such as Apache Maven, Gradle, npm) required to complete the task. You just specify your source code’s location and select settings for your build, such as the build environment to use and the build commands to run during a build.
    • AWS CodeBuild builds your code and stores the artifacts into an Amazon S3 bucket, or you can use a build command to upload them to an artifact repository.
    • AWS CodeBuild provides build environments for
      • Java
      • Python
      • Node.js
      • Ruby
      • Go
      • Android
      • .NET Core for Linux
      • Docker
    • You can define the specific commands that you want AWS CodeBuild to perform, such as installing build tool packages, running unit tests, and packaging your code.
    • You can choose from three levels of compute capacity that vary by the amount of CPU and memory to best suit your development needs.
      • Build.general1.small – 3GB memory, 2 vCPU
      • Build.general1.medium – 7GB memory, 4 vCPU
      • Build.general1.large – 15GB memory, 8 vCPU
    • You can integrate CodeBuild into existing CI/CD workflows using its source integrations, build commands, or Jenkins integration.
    • CodeBuild can connect to AWS CodeCommit, S3, GitHub, GitHub Enterprise, and Bitbucket to pull source code for builds.
    • CodeBuild allows you to use Docker images stored in another AWS account as your build environment, by granting resource level permissions.
    • It now allows you to access Docker images from any private registry as the build environment. Previously, you could only use Docker images from public DockerHub or Amazon ECR in CodeBuild.
    • You can access your past build results through the console, CloudWatch, or the API. The results include outcome (success or failure), build duration, output artifact location, and log location.
    • You can automate your release process using AWS CodePipeline to test your code and run your builds with CodeBuild.
  • Steps in a Build Process
    • CodeBuild will create a temporary compute container of the class defined in the build project
    • CodeBuild loads it with the specified runtime environment
    • CodeBuild downloads the source code
    • CodeBuild executes the commands configured in the project
    • CodeBuild uploads the generated artifact to an S3 bucket
    • Then it destroys the compute container
  • Build Duration is calculated in minutes, from the time you submit your build until your build is terminated, rounded up to the nearest minute.
  • You can save time when your project builds by using a cache. A build project can use one of two types of caching:
    • Amazon S3 – stores the cache in an Amazon S3 bucket that is available across multiple build hosts. This is a good option for small intermediate build artifacts that are more expensive to build than to download. Not the best option for large build artifacts because they can take a long time to transfer over your network, which can affect build performance.
    • Local – stores a cache locally on a build host that is available to that build host only. This is a good option for large intermediate build artifacts because the cache is immediately available on the build host. Build performance is not impacted by network transfer time.
    • If you use a local cache, you must choose one or more of three cache modes:
      • source cache
      • Docker layer cache
      • custom cache.

Monitoring and Security

    • You can specify a key stored in the AWS Key Management Service to encrypt your artifacts.
    • CodeBuild provides security and separation at the infrastructure and execution levels.
    • You can use Amazon CloudWatch to watch your builds, report when something is wrong, and take automatic actions when appropriate.
    • You can monitor your builds at two levels:
      • At the project level: These metrics are for all builds in the specified project only.
      • At the AWS account level: These metrics are for all builds in one account
    • ProjectName is the only AWS CodeBuild metrics dimension. If it is specified, then the metrics are for that project. If it is not specified, then the metrics are for the current AWS account.

AWS CodeBuild Pricing

    • You are charged for compute resources based on the duration it takes for your build to execute. The per-minute rate depends on the compute type you use.

Building in an Automated Environment with Continuous Integration:

Additional Training Materials: AWS CodeBuild Video Courses on Udemy

  1. AWS CodeCommit CodeBuild CodeDeploy CodePipeline | Hands On

AWS CodeBuild Cheat Sheet References:

https://aws.amazon.com/codebuild/features/?nc=sn&loc=2
https://aws.amazon.com/codebuild/pricing/?nc=sn&loc=3
https://aws.amazon.com/codebuild/faqs/?nc=sn&loc=5
https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started.html

Free AWS Courses

Get 20% Off – Christmas Big Sale on All Practice Exams, Video Courses, and eBooks!

Tutorials Dojo portal

Learn AWS with our PlayCloud Hands-On Labs

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

FREE AWS, Azure, GCP Practice Test Samplers

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

Follow Us On Linkedin

Recent Posts

Written by: Jon Bonso

Jon Bonso is the co-founder of Tutorials Dojo, an EdTech startup and an AWS Digital Training Partner that provides high-quality educational materials in the cloud computing space. He graduated from Mapúa Institute of Technology in 2007 with a bachelor's degree in Information Technology. Jon holds 10 AWS Certifications and is also an active AWS Community Builder since 2020.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?