DOP-C02 SDLC Automation Practice Question
Exhibit
Refer to the exhibit.
buildspec.yaml:
version: 0.2
phases:
install:
runtime-versions:
nodejs: 14
commands:
- npm install
build:
commands:
- npm run build
artifacts:
files:
- '**/*'
base-directory: build
discard-paths: noRefer to the exhibit. A developer has a buildspec.yaml for a React application. The build completes successfully, but the artifacts output is empty. What is the most likely cause?
⚠ Common exam trap
Many exam-takers assume an empty artifacts output must be caused by a syntax error in the files pattern or a missing install phase, rather than recognizing that a valid but incorrect `base-directory` path silently produces no artifacts.
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
✓
The base-directory specified does not exist after the build phase.
The most likely cause is that the `base-directory` specified in the `artifacts` section of the buildspec.yaml does not exist after the build phase completes. CodeBuild uses the `base-directory` to locate the files to package as artifacts; if the directory is missing (e.g., because the build output was written to a different path or the directory name was misspelled), no files are found, resulting in an empty artifacts output. This is a common misconfiguration when the build process generates files in a subdirectory that does not match the declared `base-directory`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The base-directory specified does not exist after the build phase.
Why this is correct
The 'base-directory' value in the artifacts block points to a path that CodeBuild expects to exist when it attempts to upload artifacts after the build phase completes. If your build commands generate output inside 'dist', for example, then specifying a base-directory like 'build' will cause an 'artifact base-directory does not exist' failure because that directory was never created or populated. CodeBuild does not automatically compile or copy files; it simply packages whatever is present under the specified path at that moment. Therefore this is the correct reason for the error, not an invalid pattern or runtime.
- ✗
The install phase did not run because npm install is not in the correct phase.
Why it's wrong here
The install phase is a legitimate top-level key in a buildspec and executes before pre_build and build, so placing 'npm install' under 'install.commands' is syntactically correct. CodeBuild's phase order is fixed: install, pre_build, build, post_build — any commands listed there run as expected and do not prevent the build phase from running. The failure occurs later, during artifact collection, because of a missing directory, not because npm install was skipped or misplaced.
- ✗
The artifacts files pattern '**/*' is invalid.
Why it's wrong here
The files pattern '**/*' is a glob pattern that recursively matches every file and directory under the base-directory; it is the standard way to include all build output. CodeBuild uses glob matchers that support double-asterisk for zero or more directories, so this pattern is entirely valid. An invalid pattern would be something like an absolute path outside the workspace or a malformed expression, but '**/*' is accepted and commonly used in buildspec artifacts.
- ✗
The runtime version nodejs 14 is not supported by CodeBuild.
Why it's wrong here
CodeBuild's standard Amazon Linux images include multiple Node.js runtime versions, and Node.js 14 is officially supported as a runtime for the 'nodejs' environment. The buildspec snippet correctly declares 'runtime: nodejs:14' and it will resolve to an available image tag in the CodeBuild managed image. If the runtime version were unsupported, CodeBuild would fail during environment provisioning, but the error described here is about the artifacts path, not the runtime.
Go deeper
Related to this question
About these practice questions
Courseiva writes every DOP-C02 question from scratch — 1,298 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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DOP-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 DOP-C02 exam.