DOP-C02 SDLC Automation Practice Question
A company uses AWS CodeBuild to compile and test their Java application. The build takes about 20 minutes. They have enabled Amazon S3 cache to store the Maven repository to speed up subsequent builds. However, they notice that the build time has not improved significantly. The buildspec file includes the 'cache' section with 'paths' pointing to '/root/.m2'. The CodeBuild project has cache type set to 'S3' and a valid bucket. The build logs show that the cache is being downloaded and uploaded, but the Maven dependencies are still being downloaded from the internet each time. What is the most likely cause?
⚠ Common exam trap
The trap is assuming the cache section is misconfigured when the logs prove it is working — the real issue is a path mismatch between the cached directory and Maven's actual local repository.
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 Maven dependencies are not being stored in the local repository path specified in the cache.
The cache is being downloaded and uploaded, but Maven still fetches dependencies from the internet, which means the dependencies are not actually landing in /root/.m2 during the build. This typically happens when the build runs as a non-root user (e.g., the CodeBuild default user), so Maven writes to a different local repository path such as /home/codebuild/.m2 or a path defined by settings.xml. The cache section is syntactically correct, so the fix is to align the cached path with the actual Maven local repository location.
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 cache is too large and takes as long to download as the build itself.
Why it's wrong here
Although a very large cache archive (S3 cache) can add noticeable download/upload time, the log shows dependencies being fetched from the internet even after the cache is downloaded. This indicates a cache miss at the content level, not a performance issue; if the cache were truly being restored, Maven would resolve artifacts from the cached local repository regardless of archive size. Therefore, cache size is not the root cause.
- ✗
The S3 bucket is in a different region than the CodeBuild project.
Why it's wrong here
CodeBuild supports Amazon S3 cache buckets in a different AWS Region from the project, so this is not a configuration error. A cross-region bucket adds network latency, but the cache would still be downloaded and extracted. The real symptom—Maven still hitting the internet—means the cached files were either not restored or are not located where the build expects them, which has nothing to do with regional placement.
- ✗
The buildspec file does not include the 'cache' section correctly.
Why it's wrong here
The scenario explicitly states that the buildspec file contains a cache section, so missing or malformed cache configuration is not the cause. Even a correctly formed cache section only controls where files are stored and restored; if it points to an empty or unused local path, Maven's own dependency downloads will continue. Thus, this option does not explain the observed behavior.
- ✓
The Maven dependencies are not being stored in the local repository path specified in the cache.
Why this is correct
If the Maven local repository is overridden (e.g., via a custom settings.xml, the -Dmaven.repo.local flag, or a different user's home directory), the path declared in CodeBuild's cache section will not contain the downloaded dependencies. The build will then re-download artifacts every time because the restore phase puts files into a location Maven never reads. The fix is to ensure the cache path exactly matches the effective local repository path used by the Maven build.
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
This DOP-C02 question is part of Courseiva's 1,298-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on DOP-C02
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A company uses AWS CodeBuild to run unit tests and package a Java application. The build process takes 15 minutes. The team wants to reduce build time by caching dependencies. Which approach should the engineer recommend?
easy- A.Store the compiled dependencies in a separate CodeCommit repository and clone it during the build
- B.Mount an Amazon EFS file system to the build container and persist the cache across builds
- C.Use an Application Load Balancer in front of a private artifact repository
- ✓ D.Configure CodeBuild to use Amazon S3 for cache storage and specify the cache directory in buildspec.yml
Why D: CodeBuild natively supports Amazon S3 for cache storage, allowing you to persist dependency directories across builds. By specifying the cache type as S3 and the path to the dependency cache (e.g., /root/.m2 for Maven) in the buildspec.yml, subsequent builds can reuse previously downloaded dependencies, significantly reducing build time without additional infrastructure.
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint
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.