DOP-C02 SDLC Automation Practice Question
Exhibit
Refer to the exhibit.
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
commands:
- npm install
build:
commands:
- npm run build
artifacts:
files:
- '**/*'
discard-paths: yesRefer to the exhibit. A team uses this buildspec.yml file in AWS CodeBuild. After the build, they expect the artifacts to be placed in a folder structure, but all files are in the root of the output artifact. What is the reason?
⚠ Common exam trap
Many candidates assume the `files` glob pattern `**/*` automatically flattens the structure, but in CodeBuild, path flattening is controlled solely by the `discard-paths` boolean, not by the glob syntax itself.
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 'discard-paths' option is set to 'yes', which flattens the directory structure.
The `discard-paths` option in the `artifacts` section of a buildspec.yml file, when set to `yes`, explicitly flattens the directory structure. This means that even if the `files` glob pattern `**/*` matches files in subdirectories, they are all placed at the root of the output artifact, discarding their original relative paths. Without this setting (or when set to `no`), the directory hierarchy would be preserved.
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 'files' section only includes '**/*' which does not preserve paths.
Why it's wrong here
The glob pattern '**/*' in the files list does not inherently flatten directories; it simply matches all files and subdirectories recursively. In CodeBuild, path preservation is determined by the discard-paths setting, which overrides any path information captured by the glob. Because discard-paths is set to 'yes', the files are placed in the artifact root, but the files pattern itself is not the cause of the flattening.
- ✓
The 'discard-paths' option is set to 'yes', which flattens the directory structure.
Why this is correct
In CodeBuild buildspec artifacts, setting discard-paths to 'yes' explicitly instructs CodeBuild to strip all directory information from the matched files. As a result, every file selected by the files glob is placed directly into the artifact root, losing any subdirectory hierarchy. This is the exact mechanism responsible for the observed flat output structure.
- ✗
The 'base-directory' is not specified, so CodeBuild uses the root of the build output.
Why it's wrong here
The base-directory attribute defines the relative location from which the files patterns are evaluated, defaulting to the build's root directory when omitted. It changes where artifact discovery begins, but it has no effect on how directories are preserved within the final artifact. Path flattening is exclusively controlled by discard-paths, so the absence of base-directory does not explain the loss of structure.
- ✗
The 'name' property is missing, causing artifacts to be stored without structure.
Why it's wrong here
The name property specifies the artifact file name or S3 object key prefix, not the layout of files inside the archive. If omitted, CodeBuild applies a default naming convention, but the internal directory structure remains governed by the discard-paths option. Therefore, a missing name cannot cause artifacts to be stored without structure, making this explanation incorrect.
Go deeper
Related to this question
About these practice questions
One of 1,013 original DOP-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.