Question

Difficulty: HardAPI Development and Integration with Amazon API Gateway

A developer is designing a high-throughput REST API using Amazon API Gateway that integrates directly with Amazon DynamoDB via an AWS Service integration. The API must write client request payloads directly to a DynamoDB table. The developer needs to ensure that:

1. The incoming JSON payload is validated to confirm it contains all required fields before calling DynamoDB.
2. The DynamoDB JSON response is transformed into an XML payload with a Content-Type of `application/xml` before being sent back to the client.

Which two configurations must the developer perform in Amazon API Gateway to meet these requirements? (Select TWO.)

  1. Define a JSON schema Model for the request payload, and configure a Request Validator on the API method to validate the request body.Answer
  2. Define a Method Response for a `200200` status code, and configure an Integration Response mapping template for the `application/xml` Content-Type to transform the DynamoDB response.Answer
  3. C
    Configure a Lambda Authorizer to validate the request payload schema and return the transformed XML payload to the client in the authorization response context.
  4. D
    Enable a Lambda Proxy Integration and write a Velocity Template Language (VTL) mapping template to parse the incoming request body.
  5. E
    Configure a CORS configuration on the API resource to automatically format the output content type to `application/xml` for the client.

Answer

The developer must define a JSON schema Model for the request payload and associate it with a Request Validator to check the request body. Additionally, they must configure a Method Response for the `200200` status code and map the response via an Integration Response template configured for the `application/xml` Content-Type.
To perform validation on incoming request bodies directly at the API Gateway layer, a JSON schema Model must be mapped to the request body, and a Request Validator must be configured on the method. To convert the database JSON payload to XML, a Method Response must first be defined for the desired response code, and an Integration Response must use a mapping template configured for the `application/xml` Content-Type.

Step-by-Step Solution

1
Create a JSON schema representing the expected request structure and register it as an API Gateway Model.
The model definition dictates the required fields and types for incoming client request payloads.
Request validation requires a predefined model schema to compare incoming client payloads against.
2
Enable request validation on the API Gateway method and target the request body using the newly created Model.
API Gateway automatically validates incoming request payloads and rejects invalid requests with a `400400 Bad Request` response, preventing unnecessary backend execution.
Offloading validation to the API Gateway edge saves backend processing capacity and cost.
3
Configure the Method Response and Integration Response with a mapping template targeting the `application/xml` Content-Type.
API Gateway processes the DynamoDB JSON response using the VTL mapping template and formats the final payload into XML with the appropriate content headers.
Custom integrations (like AWS service integrations) require mapping templates to translate responses from the backend format to the client's preferred format.

Key Concept

Amazon API Gateway Request Validation and Integration Response Mapping
Estimated Time:2m 0s
Rate this question