Question

Difficulty: HardAPI Development and Integration with Amazon API Gateway

An organization is exposing a database via a REST API using Amazon API Gateway. The developer configures an AWS Service Integration to retrieve user records directly from an Amazon DynamoDB table without using a compute layer like AWS Lambda. The API must receive requests containing a username path parameter, query the DynamoDB table, and return a simplified JSON payload to the client instead of the standard DynamoDB attribute-value JSON format. Which two configuration steps must the developer perform in API Gateway to meet these requirements?

  1. Create an Integration Request mapping template with an application/json Content-Type that uses Velocity Template Language (VTL) to format the payload for the DynamoDB GetItem action.Answer
  2. Configure an Integration Response mapping template with an application/json Content-Type to transform the DynamoDB attribute-value JSON response into the desired simplified client JSON schema.Answer
  3. C
    Enable Integration Proxy settings on the API Gateway resource to allow automatic payload transformation and parameter mapping between API Gateway and DynamoDB.
  4. D
    Configure a Method Response mapping template to define the query parameters and payload schema sent to the DynamoDB integration endpoint.
  5. E
    Implement a Lambda Authorizer to validate the request credentials and rewrite the response payload received from the DynamoDB integration.

Answer

The correct configurations are to create an Integration Request mapping template using Velocity Template Language (VTL) to format the DynamoDB GetItem payload, and to configure an Integration Response mapping template to transform the DynamoDB attribute-value response into clean client-facing JSON.
For an AWS Service Integration directly communicating with a backend database like DynamoDB, API Gateway must translate the HTTP request into the database's native API structure, which is accomplished via an Integration Request mapping template. Similarly, the database's response must be transformed from the attribute-value layout to clean JSON via an Integration Response mapping template.

Step-by-Step Solution

1
Determine the type of integration needed.
Identify that a direct AWS Service Integration with DynamoDB is required, which utilizes custom mappings rather than a proxy integration.
Since there is no intermediate compute layer (like Lambda) and payload translation is needed, a non-proxy AWS Service Integration is the correct choice.
2
Configure the incoming data transformation.
Create an Integration Request mapping template using VTL to extract the path parameter and format the DynamoDB GetItem API payload.
DynamoDB APIs require a strict JSON structure containing keys and attribute type descriptors; the mapping template translates the REST client call into this structure.
3
Configure the outgoing data transformation.
Create an Integration Response mapping template to map the DynamoDB attribute-value response to simple JSON keys.
The database response contains raw DynamoDB JSON types (e.g., {'S': 'value'}). The template flattens this structure before delivering it to the client.

Key Concept

API Gateway AWS Service Integration mapping templates (Request and Response)
Estimated Time:2m 0s
Rate this question