An application team wants to minimize unnecessary backend processing by validating client requests directly at the API Gateway layer before invoking a downstream AWS Lambda function. The REST API must verify that client requests contain a valid JSON payload matching a specific schema, and automatically reject invalid requests with an HTTP Bad Request error. Which two configuration steps should the developer perform in Amazon API Gateway to achieve this? (Select TWO.)
- Create a Model in the API Gateway console that defines the JSON Schema of the expected request payload.Cevap
- In the Method Request settings, select a Request Validator that validates the request body, and associate the request body content type with the created Model.Cevap
- CIn the Integration Request settings, configure a mapping template that uses Apache Velocity Template Language (VTL) to validate the payload structure and reject invalid requests.
- DCreate a custom Lambda Authorizer that receives the request payload, validates the schema, and returns an IAM policy with a Deny effect if required fields are missing.
- EIn the Method Response settings, define a Gateway Response of type Bad Request Body and map it to the execution role of the backend Lambda function.
Cevap
To perform request validation in API Gateway, the developer must create a Model that defines the expected JSON Schema of the payload and configure the Method Request settings by selecting a Request Validator for the request body while mapping the content type to the created Model.
To perform request body validation in API Gateway before invoking a backend Lambda function, the developer must define the structure of the request payload using a Model (defined via JSON Schema) and enable request validation in the Method Request settings by selecting a Request Validator (e.g., 'Validate body') and associating the content type (e.g., 'application/json') with that Model. This ensures that malformed requests are rejected immediately at the API Gateway level, saving backend resources.
Adım Adım Çözüm
Anahtar Kavram
Request Validation using API Gateway Models and Request Validators
Tahmini Süre:2m 0s