Courseiva
Development with AWS ServicesmediumMultiple ChoiceObjective-mapped

DVA-C02 Development with AWS Services Practice Question

A developer is building a serverless application using AWS SAM. The application includes an Amazon API Gateway endpoint with a Lambda function that processes user uploads. The developer wants to enable API caching in the development stage to speed up repeated requests, but disable caching in the production stage. What is the most efficient way to achieve this?

⚠ Common exam trap

Test-takers frequently think caching must be configured per-deployment manually (Option C) or that separate templates are required (Option B), missing the power of CloudFormation conditions to conditionally enable features within a single SAM template.

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

Configure caching in the SAM template using the CacheClusterEnabled property and use CloudFormation conditions to enable it only in the dev stage.

AWS SAM extends AWS CloudFormation, allowing you to use CloudFormation conditions to conditionally enable the `CacheClusterEnabled` property on the `AWS::ApiGateway::Stage` resource. By defining a condition that evaluates to true only for the dev stage (e.g., based on a parameter like `StageName`), you can enable caching in dev and disable it in prod within a single SAM template, avoiding duplication and manual 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.

  • Configure caching in the SAM template using the CacheClusterEnabled property and use CloudFormation conditions to enable it only in the dev stage.

    Why this is correct

    This is the most robust and automated approach. The AWS::Serverless::Api resource in a SAM template can define Stage properties, including CacheClusterEnabled. By integrating a CloudFormation Condition that evaluates a StageName parameter, caching can be enabled specifically for the dev stage while remaining disabled for prod, all within a single, version-controlled template. This ensures consistent, environment-specific deployments via CI/CD pipelines.

  • Create two separate SAM templates, one for dev with caching and one for prod without.

    Why it's wrong here

    Maintaining two distinct SAM templates for different environments introduces significant operational overhead and increases the risk of configuration drift. Any common updates or bug fixes would need to be applied to both templates, potentially leading to inconsistencies or missed changes. A single, parameterized template leveraging CloudFormation conditions is the standard and more efficient practice for managing environment-specific configurations.

  • Enable caching in the API Gateway console after each deployment for the dev stage.

    Why it's wrong here

    Manually enabling caching through the API Gateway console after each deployment contradicts the principles of Infrastructure as Code (IaC) and automation. This approach is highly inefficient, prone to human error, and not repeatable, especially in a CI/CD pipeline. It would lead to inconsistent environments and make rollback or disaster recovery scenarios more complex and unreliable.

  • Use a custom CloudFormation resource to toggle caching based on a parameter.

    Why it's wrong here

    While custom CloudFormation resources offer flexibility for unsupported AWS features or third-party integrations, using one to toggle API Gateway caching is unnecessary over-engineering. API Gateway's caching is a native property (CacheClusterEnabled) directly supported by the AWS::ApiGateway::Stage resource (and thus AWS::Serverless::Api in SAM). Leveraging built-in CloudFormation conditions with this native property is simpler, more maintainable, and less prone to issues than developing and managing a custom resource.

Quick reference

Cloud Service Model Comparison

ModelYou ManageProvider ManagesExamples
IaaSOS, runtime, apps, dataHardware, hypervisor, networkingEC2, Azure VMs, GCP Compute Engine
PaaSApps and dataOS, runtime, middleware, hardwareElastic Beanstalk, Azure App Service
SaaSData and settings onlyEverything elseMicrosoft 365, Salesforce, Workday
FaaS / ServerlessFunction code onlyInfra, scaling, runtimeLambda, Azure Functions, Cloud Run
CaaSContainers and appsKubernetes, OS, hardwareEKS, AKS, GKE

About these practice questions

Courseiva writes every DVA-C02 question from scratch — 724 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 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.