Courseiva
DeploymenthardMultiple ChoiceObjective-mapped

DVA-C02 Deployment Practice Question

A company uses AWS CodeBuild for building and testing their application. They have a build project that runs on a Linux environment. They want to run a build in a custom Docker image that is stored in Amazon ECR. How should they configure the build project?

⚠ Common exam trap

Many candidates confuse specifying a Dockerfile to build a new image (Option A) with using an existing custom image as the build environment, leading them to overlook the direct ECR URI configuration in the environment settings.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

In the environment configuration, set the 'Image' field to the ECR image URI.

AWS CodeBuild allows you to specify a custom Docker image from Amazon ECR by entering its URI directly in the 'Image' field under the environment configuration. This enables the build to run in a container that includes all necessary dependencies, without requiring a Dockerfile in the source code or a managed image.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Add a 'Dockerfile' to the source code and specify it in the buildspec.

    Why it's wrong here

    Specifying a 'Dockerfile' within the 'buildspec.yml' file instructs CodeBuild to *build* a new Docker image from that Dockerfile during the build process. This approach is used when the build environment itself needs to be dynamically created or updated as part of the build, rather than leveraging a pre-existing image. The question implies the company wants to *use* an existing ECR image, not build a new one on the fly.

  • In the environment configuration, set the 'Image' field to the ECR image URI.

    Why this is correct

    AWS CodeBuild projects allow you to define the build environment by specifying a custom Docker image. This is achieved by navigating to the "Environment" section of the CodeBuild project configuration and setting the "Image" field directly to the Amazon ECR image URI (e.g., `aws_account_id.dkr.ecr.region.amazonaws.com/repository-name:tag`). CodeBuild will then pull this specific image from ECR to execute the build commands, ensuring a consistent and controlled build environment.

  • Use a managed image provided by AWS CodeBuild.

    Why it's wrong here

    AWS CodeBuild provides a selection of managed images, which are pre-configured Docker images maintained by AWS for common build environments (e.g., various runtimes like Java, Node.js, Python). While convenient, these managed images are generic and do not allow for the use of a company's specific, custom Docker image stored in ECR. Therefore, this option does not meet the requirement of using an *existing ECR image* that the company has prepared.

  • Configure the pipeline to pass the image URI as an environment variable.

    Why it's wrong here

    Passing the image URI as an environment variable to a CodeBuild project would only make the URI available *within* the build container once it has already started. The build environment's underlying Docker image, which CodeBuild uses to launch the container, must be specified directly in the CodeBuild project's environment configuration. Environment variables cannot dynamically change the base image that CodeBuild pulls and uses to initialize the build.

About these practice questions

Courseiva writes every DVA-C02 question from scratch — 724 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.