Courseiva
SDLC Automation →mediumMultiple Choice

DOP-C02 SDLC Automation Practice Question

A company uses AWS CodeBuild to compile and test code. The build takes 30 minutes, but the team wants to reduce build time by caching dependencies. Which approach should be used?

⚠ Common exam trap

Many exam-takers confuse caching with simply storing artifacts externally (like S3 or CodeArtifact) and fail to recognize that CodeBuild's local caching is the only option that eliminates the download overhead by persisting dependencies on the build instance 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

✓

Enable local caching in the build project configuration.

AWS CodeBuild's local caching feature allows you to cache intermediate build artifacts (such as dependencies) in a local directory on the build instance, which persists across builds for the same build project. This eliminates the need to re-download dependencies from external sources for every build, significantly reducing build time. The cache is stored in a Docker volume or S3 bucket, but the key benefit is that it is automatically managed by CodeBuild without manual download steps.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Remove unnecessary dependencies from the build specification.

    Why it's wrong here

    Removing unnecessary dependencies from the buildspec does not implement any form of caching; it only trims the package list. The build environment is still ephemeral and starts from a clean slate on every run, so every required dependency must be re-fetched unless you explicitly configure a cache. Moreover, any dependency that is actually needed for compilation, testing, or packaging will cause a build failure if removed, making this a risky and ineffective solution to reduce build time.

  • ✗

    Store dependencies in an S3 bucket and download them before each build.

    Why it's wrong here

    While you could manually download a bundled dependency archive from an S3 bucket during the pre_build phase, CodeBuild does not natively provide S3-backed caching; you would have to write custom shell logic to upload a fresh archive after each build and handle versioning, extraction, and invalidation. This custom approach is brittle, adds maintenance overhead, and is not an integrated CodeBuild feature. The correct built-in mechanism is to enable local caching, which lets CodeBuild automatically persist a designated cache directory across builds without any custom scripting.

  • ✗

    Use AWS CodeArtifact to store dependencies and pull them during build.

    Why it's wrong here

    AWS CodeArtifact is a fully managed package repository designed for publishing and storing package versions (e.g., Maven, npm, PyPI) and for proxying upstream repositories. Using CodeArtifact to pull dependencies during a build still requires network transfers—it does not reuse a local workspace or persist dependency directories across builds on the same CodeBuild instance. CodeArtifact's role is artifact management, not a per-project build cache, so it does not address the need to avoid re-downloading dependencies from scratch on every build.

  • ✓

    Enable local caching in the build project configuration.

    Why this is correct

    Enabling local caching in the CodeBuild project configuration is the officially supported way to reuse dependencies across builds. You set a cache type that includes LOCAL_CUSTOM (or use the combined LOCAL option in newer versions) and define a cache directory—for example, /root/.m2 for Maven or /root/.npm for npm—so CodeBuild saves that directory after one build and restores it at the start of the next. This avoids re-downloading or recompiling unchanged dependencies, significantly reducing build time while requiring no custom scripting or external services.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

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 →

How Courseiva writes practice questions · Editorial policy

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.