DVA-C02 Development with AWS Services Practice Question
A development team is using AWS CodeBuild to compile and test their code. They want to store build artifacts in an Amazon S3 bucket. The buildspec.yml file includes an artifacts section. Which configuration correctly specifies the output artifacts?
⚠ Common exam trap
Many exam-takers confuse the `files` key (plural, required) with `file` (singular, invalid) or `path` (used in other AWS services like CodePipeline), leading candidates to select options with incorrect key names.
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
✓
artifacts: files: - '**/*' discard-paths: no
It uses the correct `files` key with a glob pattern `'**/*'` to include all files, and `discard-paths: no` preserves the directory structure in the S3 bucket. In CodeBuild, the `artifacts` section requires `files` (not `file` or `path`) to specify which files to output, and `discard-paths` controls whether the relative path is kept.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
artifacts: files: - '**/*' discard-paths: no
Why this is correct
This configuration correctly specifies that all files and directories from the build output directory should be included as artifacts. The `files` key expects a YAML list of glob patterns, where `**/*` matches everything recursively from the `base-directory` (or root of the build output if not specified). Setting `discard-paths: no` ensures that the original directory structure of the collected files is preserved within the generated artifact archive, which is crucial for maintaining file organization during deployments.
- ✗
artifacts: base-directory: 'build' files: '**/*'
Why it's wrong here
This option contains two critical syntax errors that would prevent CodeBuild from correctly processing the artifacts. While `base-directory: 'build'` is a valid key-value pair for specifying the root directory for artifact collection, the `files` key must be followed by a YAML list of glob patterns, not a single string. CodeBuild expects `files: - '**/*'` to correctly define the artifact content, making this configuration invalid and prone to `buildspec.yml` parsing errors.
- ✗
artifacts: file: '**/*' discard-paths: no
Why it's wrong here
This option is incorrect because it uses the singular key `file` instead of the required plural `files` within the `artifacts` section of the `buildspec.yml`. The `files` key is specifically designed to accept a list of glob patterns that define which files and directories should be included in the build artifact package. Using `file` will lead to a `buildspec.yml` parsing error, causing the build to fail during the artifact collection phase due to an unrecognized configuration key.
- ✗
artifacts: path: '**/*' discard-paths: false
Why it's wrong here
This option is incorrect because `path` is not a recognized top-level key for specifying artifact content within the `artifacts` section of a CodeBuild `buildspec.yml`. CodeBuild expects the `files` key to define the glob patterns for files and directories to be collected into the artifact package. Using an unrecognized key like `path` will result in a `buildspec.yml` validation failure, preventing the build from executing successfully and collecting any intended artifacts.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
Go deeper
Related to this question
About these practice questions
One of 724 original DVA-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 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.