DOP-C02 SDLC Automation Practice Question
A DevOps team uses AWS CodeBuild to compile a Java application. The build environment is managed by AWS and runs on Linux. The team wants to speed up the build process by caching dependency directories across builds. Which configuration should the team use?
⚠ Common exam trap
Watch out — candidates often confuse Docker layer caching (used for container image builds) with local caching for dependency directories, or assume that S3 caching is the only option, overlooking the simpler and faster local cache feature.
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
✓
Enable local caching in the CodeBuild project and specify the cache location as /root/.m2
AWS CodeBuild supports local caching, which stores specified directories on the build host's local instance storage. By configuring the cache type as 'local' and specifying the cache location as `/root/.m2` (the default Maven local repository), the team can persist downloaded Maven dependencies across builds, significantly reducing build time by avoiding re-downloading dependencies.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Configure the buildspec file to use Docker layer caching
Why it's wrong here
Docker layer caching is intended for image builds where Docker reuses intermediate layers (filesystem snapshots) from successful RUN steps. It does not apply to the Maven dependencies that CodeBuild compiles directly; those downloads happen inside the build process, not inside Docker image layers. Since the project is a Java application built without a Dockerfile, configuring the buildspec for Docker layer caching will have no effect on the Maven local repository speed.
- ✗
Use the CodeBuild cache configuration to store the entire build output in a custom Docker image
Why it's wrong here
The CodeBuild cache configuration can target Amazon S3 or a local directory; it does not support building into a Docker image as a caching mechanism. Storing an entire build output into a custom Docker image would be architecturally odd and also fail to cache the Maven repository (/root/.m2) because each build starts from the same base, and image layers don't persist mutable directory contents across builds. This option misunderstands the function of the cache configuration.
- ✗
Store dependencies in an Amazon S3 bucket and download them at the start of each build
Why it's wrong here
Manually storing dependencies in Amazon S3 and downloading them at each build run is not integrated with CodeBuild's native cache reuse, so you'd have to script the archive/restore and still pay the network transfer each time. CodeBuild's cache config is designed exactly to avoid re-downloading unchanged dependency files, and it automatically places/retrieves the cache from S3 or the build host. Adding a separate pre-build download step adds complexity without leveraging CodeBuild's cache semantics, making it an inferior, incorrect choice.
- ✓
Enable local caching in the CodeBuild project and specify the cache location as /root/.m2
Why this is correct
Enabling local caching in the CodeBuild project and specifying /root/.m2 as the custom cache location precisely tells CodeBuild to preserve and restore the Maven local repository onto the same build agent across runs. This way, already-downloaded JARs are reused and Maven won't fetch them again, dramatically reducing build time. This is the documented approach for caching Maven dependencies with CodeBuild.
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
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.