# AWS CodeBuild

Cloud service · AWS. Updated 2026-11-12. Page: https://blowstack.com/tools/cloud-services-hub/aws-codebuild

> AWS CodeBuild is a fully managed build service that compiles source code, runs tests, and produces software packages ready to deploy, without the need for provisioning, managing, or scaling your own build servers.

Practice exams covering AWS CodeBuild: [CLF-C02 AWS Certified Cloud Practitioner](https://blowstack.com/practice-exams/aws-certified-cloud-practitioner), [SOA-C03 AWS Certified CloudOps Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate), [DEA-C01 AWS Certified Data Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional), [AIP-C01 AWS Certified Generative AI Developer - Professional](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional), [MLA-C02 AWS Certified Machine Learning Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate), [SCS-C03 AWS Certified Security - Specialty](https://blowstack.com/practice-exams/aws-certified-security-specialty), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 7 key features of AWS CodeBuild

AWS CodeBuild is a fully managed, scalable build service that integrates with AWS and third-party tools, supports custom build environments, ensures security and compliance, and operates on a pay-as-you-go pricing model.

1. **Fully Managed Build Service**: 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, there's no need to provision, manage, or scale your own build servers.
2. **Continuous Scaling**: CodeBuild automatically scales to meet the volume of build requests. It can process multiple builds concurrently.
3. **Integrated with AWS Services**: CodeBuild is integrated with various AWS services such as Amazon S3, EC2, Elastic Container Service (ECS), and Lambda for storing, accessing, and deploying applications. This integration helps in seamless deployment and management of your applications.
4. **Pay as You Go**: With AWS CodeBuild, you only pay for the compute resources you use. There's no upfront fee or long-term commitment, making it a cost-effective option for projects of any size.
5. **Security and Compliance**: CodeBuild is compliant with various compliance programs and incorporates encryption to secure your builds. It allows you to use your own encryption keys for added security, ensuring that your build process meets the necessary compliance requirements.
6. **Custom Build Environments**: It allows the creation of custom build environments for your build jobs. You can define the operating system, programming languages, and build tools you need, giving you full control over the build environment.
7. **Integration with Development Tools**: AWS CodeBuild integrates seamlessly with other AWS Developer Tools like AWS CodePipeline for continuous integration and delivery, and it can also integrate with third-party developer tools, fostering a smooth CI/CD process.

## Where AWS CodeBuild is used

AWS CodeBuild's use cases span from facilitating Continuous Integration, automating deployments, enabling Infrastructure as Code, creating Docker container images, to executing integration testing, providing a comprehensive solution for automated building, testing, and deployment tasks.

1. **Continuous Integration**: AWS CodeBuild facilitates Continuous Integration (CI) by automatically building code submissions as part of the version control process. It ensures that new code changes are automatically compiled, tested, and prepared for deployment, enabling teams to detect integration errors quickly.
2. **Automated Deployment**: This use case involves leveraging CodeBuild to compile, test, and generate deployment artifacts that can be automatically deployed to various environments using AWS CodeDeploy. This automation streamlines the deployment process, reducing the potential for human error.
3. **Infrastructure as Code**: AWS CodeBuild can be used in conjunction with AWS CloudFormation to create and manage AWS resources. By automating the build and deployment of infrastructure code, teams can rapidly provision and configure environments in a repeatable manner.
4. **Docker Container Image Creation**: CodeBuild supports the creation of Docker container images as part of the build process. This means developers can use CodeBuild to compile their applications, package them into Docker images, and push these images to Amazon Elastic Container Registry (ECR) or other registries, making it easier to deploy containerized applications.
5. **Integration Testing**: AWS CodeBuild can be configured to automatically execute a suite of integration tests as part of the build process. This ensures that code changes work correctly together and with existing systems, helping to maintain high-quality code bases.

## How AWS CodeBuild is priced

AWS CodeBuild offers a Pay-as-you-Go model based on resource consumption during the build process and includes a Free Tier offering 100 build minutes of the build.general1.small compute type per month.

- **On-demand Amazon EC2**: On-demand EC2 builds are charged according to the selected compute instance type. Build duration is measured from submission until termination and rounded up to the nearest minute.
- **Free Tier**: The Free Tier includes 100 total monthly on-demand EC2 build minutes using general1.small or arm1.small, and 6,000 total monthly on-demand Lambda build seconds using lambda.arm.1GB or lambda.x86-64.1GB. Reserved capacity EC2, Sandbox, and Docker image server have no Free Tier. The CodeBuild Free Tier is available to new and existing AWS customers and does not automatically expire after the 12-month AWS Free Tier term.
- **On-demand AWS Lambda**: Lambda compute builds are billed from submission until termination, rounded up to the nearest second, with rates varying by the selected memory-based compute type.
- **Reserved capacity Amazon EC2**: Reserved capacity is billed by instance type from the request for a new instance until termination, rounded up to the nearest minute, with a minimum usage charge of 60 minutes per instance.
- **Mac reserved instances**: Each Mac reserved instance has a minimum usage charge of 24 hours before it can be released.
- **Incremental storage**: Incremental storage is charged per GB per minute on each instance where it is enabled.
- **Managed Network Access Control List**: Managed NACL routes traffic through a CodeBuild-managed proxy to enforce allowed or denied network rules on reserved capacity fleets. The proxy is charged per minute on each enabled fleet, and charges continue until it is disabled.
- **Docker image server**: A remote Docker image server with a shared layer cache is charged per second on each enabled project, with rates varying by server compute type. Servers remain active for up to one hour awaiting requests during cooldown; when stopped after inactivity, their persistent cache incurs a lower at-rest charge. Charges continue until the feature is disabled.
- **Sandbox**: Sandbox usage is billed from sandbox start until termination, rounded up to the nearest second.
- **Additional charges**: Builds may incur additional charges for data transfer and other AWS services, including CloudWatch Logs for build log streams, Amazon S3 for artifact storage, AWS KMS for encryption, and CodePipeline when used with CodeBuild.

## Services AWS CodeBuild works with

- **[AWS CodePipeline](https://blowstack.com/tools/cloud-services-hub/aws-codepipeline)**: CodeBuild can be integrated into CodePipeline as a build stage to automate building and testing of code as part of a continuous integration and continuous delivery (CI/CD) pipeline.
- **[Amazon S3](https://blowstack.com/tools/cloud-services-hub/amazon-s3)**: CodeBuild can use Amazon S3 to store build artifacts, source code, and log files. It can also retrieve source code from S3 buckets.
- **[AWS Identity and Access Management (IAM)](https://blowstack.com/tools/cloud-services-hub/aws-identity-and-access-management-(iam))**: IAM roles and policies can be used to control access to CodeBuild resources and define permissions for accessing other AWS services.
- **[Amazon CloudWatch](https://blowstack.com/tools/cloud-services-hub/amazon-cloudwatch)**: CodeBuild integrates with Amazon CloudWatch to provide build log data, metrics, and events that can be monitored for operational health and debugging purposes.
- **[AWS Secrets Manager](https://blowstack.com/tools/cloud-services-hub/aws-secrets-manager)**: Secrets Manager can store sensitive information such as database credentials that can be securely accessed by CodeBuild during the build process.
- **[Amazon CodeGuru](https://blowstack.com/tools/cloud-services-hub/amazon-codeguru)**: CodeBuild can incorporate CodeGuru Security's CI/CD scanning integration into a build to analyze source code for security vulnerabilities and produce findings before artifacts are released.
- **[Amazon Corretto](https://blowstack.com/tools/cloud-services-hub/amazon-corretto)**: CodeBuild's managed build images provide Amazon Corretto runtimes for Java builds. A buildspec can select an available Corretto version to compile and test a Java application.
- **[Amazon EC2](https://blowstack.com/tools/cloud-services-hub/amazon-ec2)**: CodeBuild offers EC2-based build environments and reserved-capacity fleets backed by EC2 instances. These environments support workloads that need capabilities such as privileged Docker builds or customized compute capacity.
- **[Amazon Elastic Container Registry (Amazon ECR)](https://blowstack.com/tools/cloud-services-hub/amazon-elastic-container-registry-(amazon-ecr))**: CodeBuild can pull custom build-environment images from private ECR repositories and authenticate to ECR to publish container images produced during a build.
- **[Amazon Elastic File System (Amazon EFS)](https://blowstack.com/tools/cloud-services-hub/amazon-elastic-file-system-(amazon-efs))**: CodeBuild projects can mount EFS file systems into their build environments through a configured VPC connection. Builds can use the mounted directories for shared dependencies, large datasets, or persistent build files.
- **[Amazon EventBridge](https://blowstack.com/tools/cloud-services-hub/amazon-eventbridge)**: CodeBuild sends build-state and build-phase events to EventBridge for event-driven automation. EventBridge rules and schedules can also start CodeBuild builds.
- **[Amazon Q](https://blowstack.com/tools/cloud-services-hub/amazon-q)**: CodeBuild integrates with Amazon Q Developer to help investigate failed builds. From a failed build, developers can request analysis of the build's errors and suggested troubleshooting steps.
- **[Amazon SageMaker](https://blowstack.com/tools/cloud-services-hub/amazon-sagemaker)**: CodeBuild runs build and test steps in CI/CD pipelines created by SageMaker Projects templates. Depending on the template, these steps can package model-building code, build container images, or test models before deployment.
- **[Amazon Simple Notification Service (Amazon SNS)](https://blowstack.com/tools/cloud-services-hub/amazon-simple-notification-service-(amazon-sns))**: CodeBuild notification rules can deliver build-event notifications to SNS topics. Subscribers can receive alerts when builds fail, succeed, or require attention.
- **[Amazon VPC](https://blowstack.com/tools/cloud-services-hub/amazon-vpc)**: CodeBuild projects can attach their build environments to selected VPC subnets and security groups. This lets builds access private resources, such as internal dependency repositories, without exposing those resources publicly.
- **[AWS Amplify](https://blowstack.com/tools/cloud-services-hub/aws-amplify)**: CodeBuild supplies managed build infrastructure used by Amplify Hosting to process application source. Amplify build settings control steps such as installing dependencies, compiling the application, and producing deployment artifacts.
- **[AWS App Runner](https://blowstack.com/tools/cloud-services-hub/aws-app-runner)**: CodeBuild provides the managed build infrastructure used by App Runner's source-code deployment workflow. App Runner uses the resulting container image to deploy and run the application.
- **[AWS Chatbot](https://blowstack.com/tools/cloud-services-hub/aws-chatbot)**: CodeBuild notification rules can target chat clients configured through AWS Chatbot. Build-status notifications can then appear in supported Slack or Microsoft Teams channels.
- **[AWS CloudFormation](https://blowstack.com/tools/cloud-services-hub/aws-cloudformation)**: CodeBuild projects, report groups, source credentials, and reserved-capacity fleets can be provisioned through CloudFormation resource types. Templates can define build environments, source settings, artifact destinations, and service roles alongside the rest of an application's infrastructure.
- **[AWS CloudTrail](https://blowstack.com/tools/cloud-services-hub/aws-cloudtrail)**: CodeBuild API activity is recorded by CloudTrail, including requests to create projects, change their configuration, and start builds. These records support auditing who initiated builds or modified build infrastructure.
- **[AWS CodeArtifact](https://blowstack.com/tools/cloud-services-hub/aws-codeartifact)**: CodeBuild can authenticate its package managers to CodeArtifact repositories during a build. Builds can download private dependencies and publish newly built packages using the project's service-role permissions.
- **[AWS CodeCommit](https://blowstack.com/tools/cloud-services-hub/aws-codecommit)**: CodeBuild supports CodeCommit repositories as a native source type and checks out the selected source revision before running a build. Repository-change events can trigger builds through EventBridge.
- **[AWS CodeConnections](https://blowstack.com/tools/cloud-services-hub/aws-codeconnections)**: CodeBuild supports CodeConnections-based authorization for supported external source repositories. A project can use a connection to retrieve repository contents without storing a personal access token in its configuration.
- **[AWS Config](https://blowstack.com/tools/cloud-services-hub/aws-config)**: CodeBuild projects and report groups are supported AWS Config resource types, allowing their configuration changes to be recorded. Config rules can also evaluate build-project settings such as artifact encryption and privileged-mode usage.
- **[AWS Key Management Service (AWS KMS)](https://blowstack.com/tools/cloud-services-hub/aws-key-management-service-(aws-kms))**: CodeBuild uses KMS keys to encrypt build output artifacts stored in S3. A project can specify a customer-managed key so artifact access is governed by that key's policy and permissions.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: CodeBuild offers a Lambda compute mode that runs supported build workloads on Lambda infrastructure. This mode provides fast startup for suitable short-lived builds without maintaining EC2 build capacity.
- **[AWS PrivateLink](https://blowstack.com/tools/cloud-services-hub/aws-privatelink)**: CodeBuild supports interface VPC endpoints through PrivateLink. Clients in a VPC can use these endpoints to call the CodeBuild API without requiring an internet gateway or NAT gateway.
- **[AWS Resource Access Manager (AWS RAM)](https://blowstack.com/tools/cloud-services-hub/aws-resource-access-manager-(aws-ram))**: CodeBuild integrates with RAM to share build projects and report groups with other AWS accounts. This allows teams to reuse centrally managed build projects or access shared test and coverage reports.
- **[AWS Resource Groups and Tag Editor](https://blowstack.com/tools/cloud-services-hub/aws-resource-groups-and-tag-editor)**: CodeBuild resources can be included in tag-based resource groups, and supported resources can be discovered and tagged through Tag Editor. Teams can organize build infrastructure by application, environment, or ownership.
- **[AWS Security Hub](https://blowstack.com/tools/cloud-services-hub/aws-security-hub)**: CodeBuild projects are evaluated by Security Hub controls covering settings such as privileged mode, credentials in environment variables, logging, and encryption. Failed checks produce findings that help identify insecure build configurations.
- **[AWS Security Token Service (AWS STS)](https://blowstack.com/tools/cloud-services-hub/aws-security-token-service-(aws-sts))**: CodeBuild assumes a project's service role through STS and uses temporary credentials to perform authorized build operations. The role's permissions govern access to resources such as source repositories, artifact buckets, and container registries.
- **[AWS Step Functions](https://blowstack.com/tools/cloud-services-hub/aws-step-functions)**: CodeBuild has an optimized Step Functions integration for starting, stopping, and inspecting builds. A state machine can use the synchronous integration to wait for a build to finish before continuing its workflow.
- **[AWS Systems Manager](https://blowstack.com/tools/cloud-services-hub/aws-systems-manager)**: CodeBuild can resolve buildspec environment variables from Systems Manager Parameter Store. Supported build environments also integrate with Session Manager for interactive debugging sessions during a build.
- **[AWS User Notifications](https://blowstack.com/tools/cloud-services-hub/aws-user-notifications)**: CodeBuild events can be selected in AWS User Notifications configurations to generate build-status alerts. Notification rules can filter events, such as failed builds, and deliver them through configured notification channels.

## What is AWS CodeBuild

AWS CodeBuild is a managed build service that compiles source code, runs tests, and produces software packages that are ready to deploy. With AWS CodeBuild, developers are liberated from setting up, managing, and scaling their own build servers. It processes each build in a separate, fresh environment that is automatically provisioned at the start of a build and torn down at the end, ensuring that the build process is not only fast but also consistent and isolated from other builds.

The beauty of AWS CodeBuild lies in its integration with other services in the Amazon Web Services ecosystem, making it a critical component in the continuous integration and delivery (CI/CD) pipeline. For instance, it integrates seamlessly with AWS CodePipeline, AWS CodeCommit, Amazon S3, and Amazon ECR, enabling developers to automate the entire software release process from code commit to deployment. This means that whenever a code change is committed to a source repository, AWS CodeBuild can automatically fetch the latest code version and trigger the build process, thereby reducing manual effort and potential human errors. AWS CodeBuild supports a wide array of programming languages and build environments such as Java, Python, Node.js, Ruby, Go, and Docker. This flexibility allows developers to use the service for a broad range of applications, from simple web applications to complex microservices architectures running in Docker containers.

Furthermore, AWS CodeBuild is capable of executing custom build commands and scripts, providing developers with the flexibility to tailor the build process according to their project's specific needs.

Builds can use on-demand instances, reserved capacity fleets, or Lambda compute, including a mix of these resources within a build batch.

Concurrently running CodeBuild builds can be subject to a concurrency quota.

Mac builds are available through reserved instances.

CodeBuild also supports non-container builds on Linux x86, Arm, and Windows on-demand fleets, running build commands directly on the host operating system.

For interactive troubleshooting, CodeBuild provides secure, isolated sandbox environments that you can connect to through an SSH client or an IDE.

Cost efficiency is another significant advantage of AWS CodeBuild. It follows a pay-as-you-go pricing model, with charges based on the resources used. This approach eliminates the need to invest in expensive, underutilized build servers, making AWS CodeBuild an economically viable solution for projects of all sizes, from startups to large enterprises.

Moreover, security is a top priority in AWS CodeBuild. It integrates with AWS Identity and Access Management (IAM), allowing developers to define specific permissions for the build process, ensuring that builds are not only isolated from one another but also secure. Build artifacts can be encrypted using a key stored in AWS Key Management Service (AWS KMS).

In conclusion, AWS CodeBuild is a robust, scalable, and cost-effective solution for automating the build process in the cloud. Its integration capabilities, support for a wide range of programming languages and build environments, pay-as-you-go pricing, and emphasis on security make it an invaluable tool for developers aiming to streamline their CI/CD pipelines and accelerate their software delivery cycle, irrespective of the size or complexity of their projects.

## Concepts related to AWS CodeBuild

- [Unit Testing](https://blowstack.com/tools/cloud-concepts-hub/unit-testing): Unit testing verifies the behavior of a small, independently testable piece of code while controlling its dependencies.
- [CI/CD](https://blowstack.com/tools/cloud-concepts-hub/cicd): CI/CD is a software engineering approach that continuously integrates code changes and automates their validation and delivery or deployment.
- [Code Coverage](https://blowstack.com/tools/cloud-concepts-hub/code-coverage): Code coverage measures how much application code is executed while automated tests run.
- [Exit Codes](https://blowstack.com/tools/cloud-concepts-hub/exit-codes): Exit codes are numeric status values that processes return when they terminate so calling systems can determine whether an operation succeeded or failed.
- [Integration Testing](https://blowstack.com/tools/cloud-concepts-hub/integration-testing): Integration testing verifies that connected software components exchange data and work together correctly across their interfaces.
- [Quality Gates](https://blowstack.com/tools/cloud-concepts-hub/quality-gates): Quality gates are explicit pass-or-fail checkpoints that use evidence to determine whether a change can advance through a delivery workflow.
- [Reproducible Builds](https://blowstack.com/tools/cloud-concepts-hub/reproducible-builds): Reproducible builds produce byte-for-byte identical artifacts when the same source code, declared inputs, and build instructions are used.
- [Security Quality Gates](https://blowstack.com/tools/cloud-concepts-hub/security-quality-gates): Security quality gates are enforced checkpoints that allow software changes to advance only when defined security acceptance criteria are satisfied.
- [Test Pyramid](https://blowstack.com/tools/cloud-concepts-hub/test-pyramid): The Test Pyramid is a testing strategy that favors many fast, focused tests, fewer integration tests, and a small set of broad end-to-end tests.
- [Webhooks](https://blowstack.com/tools/cloud-concepts-hub/webhooks): Webhooks are event-triggered HTTP callbacks that notify another application when something happens.
- [End-to-End Testing](https://blowstack.com/tools/cloud-concepts-hub/end-to-end-testing): End-to-end testing validates a complete application journey, from its entry point through integrated components to the final response and observable effects.
- [Load Testing](https://blowstack.com/tools/cloud-concepts-hub/load-testing): Load testing evaluates how a system performs under a defined workload to verify capacity, response times, reliability, and scaling behavior.
- [Performance Benchmarking](https://blowstack.com/tools/cloud-concepts-hub/performance-benchmarking): Performance benchmarking is the repeatable measurement of a system under defined workloads to compare its behavior against a baseline, alternative configuration, or performance target.
- [Regression Testing](https://blowstack.com/tools/cloud-concepts-hub/regression-testing): Regression testing checks that changes to a system do not break previously accepted behavior or degrade established quality standards.
- [Dependency Pinning](https://blowstack.com/tools/cloud-concepts-hub/dependency-pinning): Dependency pinning fixes build dependencies to explicitly selected versions or immutable identifiers so automated builds do not silently consume different inputs.
- [Static Application Security Testing](https://blowstack.com/tools/cloud-concepts-hub/static-application-security-testing): Static Application Security Testing analyzes application source code or compiled artifacts for security weaknesses without running the application.
- [UI Testing](https://blowstack.com/tools/cloud-concepts-hub/ui-testing): UI testing verifies that an application's user interface behaves correctly when users interact with it.
- [Acceptance Testing](https://blowstack.com/tools/cloud-concepts-hub/acceptance-testing): Acceptance testing verifies that a system satisfies agreed acceptance criteria and is suitable for its intended business use.
- [Fail-Fast](https://blowstack.com/tools/cloud-concepts-hub/fail-fast): Fail-Fast is the practice of detecting invalid conditions early, reporting failure explicitly, and stopping work that cannot safely succeed.
- [Shift-Left Security](https://blowstack.com/tools/cloud-concepts-hub/shift-left-security): Shift-left security integrates security design, testing, and remediation into the earliest practical stages of software development and delivery.
- [Static Analysis](https://blowstack.com/tools/cloud-concepts-hub/static-analysis): Static analysis examines code, configuration, or infrastructure definitions for defects and policy violations without executing the workload or deploying the resources being analyzed.
- [Stress Testing](https://blowstack.com/tools/cloud-concepts-hub/stress-testing): Stress testing deliberately pushes a system beyond its expected operating load or constrains its resources to evaluate failure behavior, capacity limits, and recovery.
- [Test Doubles](https://blowstack.com/tools/cloud-concepts-hub/test-doubles): Test doubles are controlled substitutes for real components or dependencies used to exercise application behavior during testing.
- [Waterfall Model](https://blowstack.com/tools/cloud-concepts-hub/waterfall-model): The Waterfall Model is a software development lifecycle approach that organizes work into sequential phases, typically completing and approving each phase before the next begins.
- [Agile Development](https://blowstack.com/tools/cloud-concepts-hub/agile-development): Agile development is an iterative, incremental approach to software delivery that adapts plans through frequent feedback, collaboration, and working software.
- [API Gateway Pattern](https://blowstack.com/tools/cloud-concepts-hub/api-gateway-pattern): The API Gateway Pattern places a controlled entry point between clients and backend services to centralize request routing and shared API policies.
- [Code Refactoring](https://blowstack.com/tools/cloud-concepts-hub/code-refactoring): Code refactoring is the restructuring of existing source code to improve its internal design without changing its externally observable behavior.
- [Contract Testing](https://blowstack.com/tools/cloud-concepts-hub/contract-testing): Contract testing verifies that communicating components satisfy agreed expectations for requests, responses, or messages at their integration boundaries.
- [Deployment Rollback](https://blowstack.com/tools/cloud-concepts-hub/deployment-rollback): Deployment rollback restores a previously validated application, infrastructure, or model release when a new deployment fails or causes unacceptable behavior.
- [Developer tools](https://blowstack.com/tools/cloud-concepts-hub/developer-tools): Developer tools are software utilities and services that help engineers write, test, debug, package, and deliver applications.
- [Gitflow](https://blowstack.com/tools/cloud-concepts-hub/gitflow): Gitflow is a Git branching workflow that separates ongoing development, release preparation, and production fixes using branches with defined roles.
- [Mocking](https://blowstack.com/tools/cloud-concepts-hub/mocking): Mocking replaces real dependencies with controlled test substitutes so application behavior can be tested in isolation.
- [Performance Profiling](https://blowstack.com/tools/cloud-concepts-hub/performance-profiling): Performance profiling measures how an application spends time and consumes resources to identify bottlenecks and guide targeted improvements.
- [Policy as Code](https://blowstack.com/tools/cloud-concepts-hub/policy-as-code): Policy as Code expresses governance and security requirements as version-controlled, machine-evaluable rules that automated workflows can test and enforce.
- [Trunk-Based Development](https://blowstack.com/tools/cloud-concepts-hub/trunk-based-development): Trunk-Based Development is a version-control strategy in which developers integrate small changes frequently into a single shared main branch, using direct commits or short-lived branches.

## AWS CodeBuild exam questions

Real practice exam questions on AWS CodeBuild, with the correct answer and its explanation.

### Question 1 (CLF-C02)

**Question:**

A development team uses a shared build server to compile an application, run unit tests, and create release packages. During busy periods, builds wait for available capacity. The team wants each build to run in an isolated environment that scales on demand, without maintaining build servers or relying on developers' computers. Which solution best meets these requirements?

**Correct answer:** Create an AWS CodeBuild project using on-demand compute to compile the application, run tests, and produce release packages.

**Explanation:** CodeBuild provides managed, isolated build environments that compile source code, run tests, and produce artifacts. On-demand compute accommodates changing build demand without the team maintaining build servers.

### Question 2 (MLA-C02)

**Question:**

An ML team uses AWS CodeBuild to test a Python component that submits training jobs. The component implements an application-level retry policy: after throttling errors, it waits 30, 60, and 120 seconds between attempts, with a maximum of four total attempts. It must immediately propagate nonretryable validation errors. Existing tests rely on a live service producing throttling errors and sometimes take several minutes. The team needs repeatable tests that verify retry counts, backoff intervals, and error propagation in less than 5 seconds without changing the production retry policy. Which approach meets these requirements?

**Correct answer:** Inject a stubbed API client and a recording replacement for the sleep function. Test scripted sequences of throttling errors, successful responses, and validation errors, asserting call counts, requested delays, and propagated exceptions.

**Explanation:** Controlled API responses make every retry scenario repeatable. Replacing sleep with a function that records requested delays eliminates waiting while preserving execution of the production retry logic. Assertions can verify recovery, the four-attempt limit, exact backoff intervals, and immediate propagation of validation errors.

### Question 3 (SAP-C03)

**Question:**

A company uses AWS CodePipeline to release a financial application. Its validation stage must run eight independent integration test suites concurrently in separate, isolated build environments. A packaging build must start only after all eight suites succeed. If any suite fails, packaging must not run and the pipeline must not proceed to deployment.

The platform team requires validation and packaging to remain behind a single CodePipeline build action. The team wants to use managed orchestration rather than maintain a script that starts builds and polls their status. Test builds write their outputs to an Amazon S3 prefix unique to the pipeline execution, and the packaging build can retrieve those outputs.

Which solution meets these requirements?

**Correct answer:** Enable batch builds for the CodePipeline CodeBuild action. Define a build graph with eight test builds and a packaging build that depends on all eight test builds. Configure the test commands to return a nonzero exit status on failure, and do not allow failures to be ignored.

**Explanation:** CodeBuild batch build graphs provide managed orchestration of separate builds with explicit dependencies. The test builds can run concurrently, and the packaging build becomes eligible only after its dependencies succeed. Propagating test failures and not ignoring them causes the batch action to fail and prevents the pipeline from advancing.

### Question 4 (SOA-C03)

**Question:**

A company uses AWS CodeBuild to run Terraform from a GitHub repository. Pull request builds must run terraform init and terraform validate, including for contributions from outside the company. Production resources must be deployed automatically after reviewed changes are merged into the protected main branch.

Contributors can modify Terraform files, scripts, and buildspec.yml in their pull requests. They cannot change CodeBuild project settings, IAM policies, or branch protection rules, and they have no direct permission to start builds. The company requires that code executed during pull request validation cannot obtain production provisioning permissions, even if a contributor submits malicious build commands.

Which solution meets these requirements?

**Correct answer:** Use separate CodeBuild projects and service roles. Give the pull request validation role no production provisioning permissions and no ability to assume a production deployment role. Configure the production project to deploy only on push events for the protected main branch, and give only its service role the required provisioning permissions.

**Explanation:** Separate projects with separate IAM roles establish a permissions boundary that pull request code cannot change. Malicious validation commands cannot obtain production permissions from their role. Filtering the production project's webhook to push events on the protected main branch ensures that automatic deployments run only after the required review and merge process.

### Question 5 (AIP-C01)

**Question:**

A company releases prompt-template updates for a generative AI assistant through AWS CodePipeline. An AWS CodeBuild action evaluates each candidate and returns a nonzero exit code when acceptance criteria are not met. The prompt repository contains the evaluation script, buildspec, and acceptance thresholds.

During an audit, the company discovers that a prompt update passed because its author also lowered the factual-correctness threshold in the same commit. The evaluation results were accurate, and the pipeline correctly enforced the modified threshold.

The company requires that prompt developers cannot weaken or bypass release criteria through changes to the prompt repository. Only the quality assurance team may modify the evaluator or acceptance policy. Candidates that meet the approved criteria must continue to deploy automatically.

Which design best meets these requirements?

**Correct answer:** Move the evaluator, buildspec, and acceptance policy to a QA-controlled location. Configure a mandatory CodeBuild action to use those protected components to evaluate candidate prompt artifacts and fail when approved criteria are not met. Restrict changes to the gate project, pipeline, and protected components to authorized administrators and QA personnel.

**Explanation:** This separates candidate-controlled artifacts from the components that authorize promotion. The mandatory action enforces QA-approved criteria, while access restrictions prevent prompt developers from replacing or bypassing it. Passing candidates can still proceed automatically.

### Question 6 (DEA-C01)

**Question:**

A data engineering team uses AWS CodeBuild to validate an AWS Glue Python shell job before production deployment. The job uses a PostgreSQL client to load each batch into an Amazon RDS database. It inserts a row into a batch_header table and then inserts the batch's records into a batch_detail table.

Both writes must commit together. If a detail-table insert fails, the job must report failure and leave no rows for that batch in either table. Existing tests verify successful loads, but a recent change enabled autocommit and caused failed loads to leave header rows behind.

An isolated test database has the same schema as production. Which additional automated check should the team run in CodeBuild to detect this type of regression?

**Correct answer:** Configure the test database to reject a detail-table insert after the header insert succeeds. Run the candidate job, require a failed job status, and use a separate database connection to verify that neither table contains rows for the test batch.

**Explanation:** This exercises the actual transaction boundary between the job and the database. A failure after the first write exposes incorrect autocommit or rollback behavior. Checking both tables through a separate connection verifies the persisted state, while checking job status confirms that the failure is reported.

### Question 7 (SCS-C03)

**Question:**

A company uses AWS CodeBuild to assess a Java web application before deployment to Amazon ECS. To reduce assessment time, the build copies only files modified by the current commit into a temporary directory and analyzes each file independently. Dependency checks report no known vulnerabilities.

A penetration test later discovers SQL injection. An unchanged HTTP handler passes a request parameter through an unchanged service class to a modified database helper that concatenates the value into a query. The code analyzer supports cross-file data-flow analysis, but the build produced no finding for this path.

The company requires the assessment to identify these paths and report the relevant source locations before deployment, without starting the application. Which change should a security engineer make?

**Correct answer:** Provide the analyzer with the complete relevant application modules and required build context from the intended commit, and enable cross-file data-flow analysis from request inputs to database operations.

**Explanation:** The current configuration removes the unchanged callers needed to establish the vulnerable data flow. Analyzing the relevant modules together allows the analyzer to trace untrusted input across method and file boundaries into the SQL operation and report source locations without executing the application.

### Question 8 (DVA-C02)

**Question:**

A team uses AWS CodeBuild to prepare an application deployment package. During the build, a script generates an application-settings.json file from environment variables configured in the CodeBuild project and includes the file in the package. These variables contain nonsecret feature selections and a data-format revision. The application reads this file and does not support runtime configuration overrides.

The team must be able to independently rebuild an approved release months later and produce an identical package. Source code, dependencies, the build toolchain, and archive generation are already controlled. However, changing the project's environment variables for a newer release causes a rebuild of an older source commit to contain different configuration.

Which change should the developer make to meet the requirement while allowing configuration changes for future releases?

**Correct answer:** Commit a release configuration file alongside the application source and generate application-settings.json exclusively from that file. Make configuration changes for future releases through new commits.

**Explanation:** This makes the packaged configuration a versioned build input. Checking out the approved commit restores its configuration as well as its code. With the other sources of output variation already controlled, independent rebuilds can reproduce the package while later commits can introduce new configuration.

### Question 9 (DOP-C02)

**Question:**

A company uses AWS CodeBuild and the AWS SAM CLI to generate artifacts for a serverless application. Several Python Lambda functions use a shared AWS::Serverless::LayerVersion resource with the logical ID NativeToolsLayer and ContentUri set to tools/. The functions invoke a compiled helper at /opt/bin/report-helper.

The tools/ directory contains C++ source code and a Makefile with an existing compilation recipe, but it does not contain the compiled executable. The CodeBuild environment has a compiler and libraries compatible with the functions' Lambda runtime and x86_64 architecture. The functions' Python dependencies already build successfully.

A DevOps engineer must integrate compilation of the helper into sam build so that the generated layer artifact contains the executable at the required location. The engineer must use SAM's custom build mechanism without adding a separate compilation step to the buildspec or committing compiled files to the repository.

Which configuration meets these requirements?

**Correct answer:** Add Metadata with BuildMethod: makefile to NativeToolsLayer. In tools/Makefile, define build-NativeToolsLayer to run the compilation recipe and copy the executable to $(ARTIFACTS_DIR)/bin/report-helper.

**Explanation:** SAM supports custom Makefile builds for layers. BuildMethod: makefile selects this mechanism, and SAM invokes the build target named build- followed by the resource's logical ID. The recipe must place its output in ARTIFACTS_DIR. Lambda extracts layer contents under /opt, so bin/report-helper in the layer becomes /opt/bin/report-helper.

## Practice AWS CodeBuild in a full exam

Questions on AWS CodeBuild in each practice exam, with every answer option and an explanation for each:

- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 89 questions
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 20 questions
- [MLA-C02](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate): 17 questions
- [AIP-C01](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional): 10 questions
- [DEA-C01](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate): 9 questions
- [SOA-C03](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate): 8 questions
- [SCS-C03](https://blowstack.com/practice-exams/aws-certified-security-specialty): 6 questions
- [CLF-C02](https://blowstack.com/practice-exams/aws-certified-cloud-practitioner): 4 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 2 questions

## Learn AWS CodeBuild in lessons

19 short lessons on AWS CodeBuild in 8 certification courses.

- CLF-C02: AWS CodeBuild: managed software builds (Premium), https://app.blowstack.com/lessons/aws-codebuild-managed-software-builds-clf-c02
- MLA-C02: AWS CodePipeline vs AWS CodeBuild: orchestration and build execution (Premium), https://app.blowstack.com/lessons/aws-codepipeline-vs-aws-codebuild-orchestration-and-build-execution-mla-c02
- SAP-C03: AWS CodeBuild vs. AWS CodePipeline: execution and orchestration (Premium), https://app.blowstack.com/lessons/aws-codebuild-vs-aws-codepipeline-execution-and-orchestration-sap-c03
- SOA-C03: AWS CodeBuild: running deployment tools with buildspecs (Premium), https://app.blowstack.com/lessons/aws-codebuild-running-deployment-tools-with-buildspecs-soa-c03
- AIP-C01: AWS CodeBuild: buildspec-driven quality gates (Premium), https://app.blowstack.com/lessons/aws-codebuild-buildspec-driven-quality-gates-aip-c01
- DEA-C01: AWS CodeBuild: automated testing with buildspecs (Premium), https://app.blowstack.com/lessons/aws-codebuild-automated-testing-with-buildspecs-dea-c01
