Courseiva
Development with AWS ServicesmediumMultiple ChoiceObjective-mapped

DVA-C02 Development with AWS Services Practice Question

A developer is using Amazon API Gateway to expose a REST API. The API needs to validate request parameters and payload before invoking the backend Lambda function. What is the MOST efficient way to perform this validation?

⚠ Common exam trap

A common mix-up: candidates assume validation must happen in the Lambda function (Option B) because they think backend logic is required, but API Gateway's built-in request validation is more efficient and is the recommended approach for schema-based validation before invocation.

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

Use API Gateway request validation with a model schema.

API Gateway's built-in request validation allows you to define a JSON Schema model that automatically validates request parameters, headers, and payload before the request reaches the backend Lambda function. This offloads validation from the Lambda function, reducing compute time and cost, and provides immediate 400 error responses without invoking the backend. It is the most efficient approach because it minimizes latency and Lambda invocations for invalid requests.

Answer analysis

Option-by-option breakdown

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

  • Use API Gateway request validation with a model schema.

    Why this is correct

    API Gateway's request validation leverages JSON Schema Draft 4 models to define the expected structure and data types for request bodies, headers, and query parameters. By configuring a validator for a method, API Gateway automatically inspects incoming requests against the defined schema. This pre-processing rejects malformed requests before they reach the backend, significantly reducing unnecessary Lambda invocations, saving costs, and improving API responsiveness.

  • Validate the request in the Lambda function and return errors if validation fails.

    Why it's wrong here

    Implementing request validation solely within the Lambda function means every incoming API request, regardless of its validity, will trigger a Lambda invocation. This incurs unnecessary costs for both the invocation count and compute duration, even for requests that would ultimately be rejected. Furthermore, it adds latency as the request must traverse to the backend before validation occurs, and places the burden of validation logic on the compute resource rather than the API management layer.

  • Use Amazon CloudFront to validate the request at the edge.

    Why it's wrong here

    Amazon CloudFront primarily functions as a Content Delivery Network (CDN) and a web application firewall (WAF) integration point, not an API request validator for payload schemas. While CloudFront can enforce some basic security rules via WAF, it lacks the native capability to understand and validate complex JSON or XML request body structures against a defined schema. Its role is to cache content and filter common web exploits, not to enforce API contract compliance at the application layer.

  • Use API Gateway request parameters to enforce required headers.

    Why it's wrong here

    While API Gateway allows developers to define and enforce required request parameters, such as specific headers, query string parameters, or path parameters, this mechanism is distinct from validating the request body's content. Enforcing required headers ensures their presence but does not inspect the structure or data types within the JSON or XML payload. Therefore, this approach is insufficient for comprehensive API request validation, as it leaves the critical payload unvalidated.

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

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 →

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.