Soru

Zorluk: OrtaAPI Development and Integration with Amazon API Gateway

A developer is creating a high-performance REST API using Amazon API Gateway that must write incoming JSON payloads directly into an Amazon DynamoDB table. To minimize latency and operational costs, the developer decides to use an AWS service integration instead of invoking an intermediate AWS Lambda function. Which two configurations are required to successfully set up this direct integration? (Select TWO.)

  1. Configure an integration request of type AWS Service, targeting DynamoDB and specifying the PutItem action, and assign an IAM role that allows API Gateway to perform the PutItem operation.Cevap
  2. Create an integration request mapping template for the application/json content type to transform the incoming JSON payload into the format required by the DynamoDB PutItem API.Cevap
  3. C
    Enable Lambda proxy integration on the method request to automatically format and forward the incoming JSON payload to the DynamoDB endpoint.
  4. D
    Configure a custom Lambda authorizer to automatically map the incoming request headers to the DynamoDB primary key attributes.
  5. E
    Configure an IAM role trust policy that allows the DynamoDB service principal (dynamodb.amazonaws.com) to assume the role used by API Gateway.

Cevap

To set up a direct API Gateway integration with DynamoDB, the developer must configure an integration request of type AWS Service targeting DynamoDB with the PutItem action and an API Gateway execution role, and create an integration request mapping template for application/json to format the payload.
To connect API Gateway directly to DynamoDB without an intermediate Lambda function, an AWS Service integration must be configured. This requires specifying the target service, action (PutItem), and an IAM execution role that allows API Gateway to write to the table. Additionally, because DynamoDB expects a specific JSON format containing attribute types (e.g., specifying string values with 'S'), an integration request mapping template is required to transform the incoming client JSON payload into the DynamoDB PutItem format.

Adım Adım Çözüm

1
Determine the integration type and backend settings.
Choose AWS Service integration, select DynamoDB, set the action as PutItem, and specify an IAM execution role.
This establishes direct API-to-service connectivity and provides permissions for API Gateway to invoke the DynamoDB endpoint.
2
Configure the trust policy for the API Gateway execution role.
Ensure the IAM role trusts the API Gateway service principal (apigateway.amazonaws.com).
API Gateway needs trust permissions to assume the execution role and perform operations on DynamoDB.
3
Define request mapping to format input JSON into DynamoDB JSON format.
Create an integration request mapping template mapping client properties into the DynamoDB PutItem structure.
DynamoDB does not accept arbitrary JSON payloads; it requires typed fields (such as S or N) to represent data attributes.

Anahtar Kavram

API Gateway Direct AWS Service Integration with DynamoDB
Bu soruyu puanla