A developer is designing a REST API in Amazon API Gateway to ingest high-frequency telemetry data from client devices. To minimize latency and operating costs, the API must write incoming JSON payloads directly to an Amazon Kinesis data stream without using an intermediate AWS Lambda function. The client payload is sent as application/json containing a telemetry event. The API Gateway integration must map the payload to the format required by the Kinesis PutRecords API, which expects base64-encoded data. Which two configuration steps must the developer perform to successfully implement this integration? (Select TWO.)
- Configure an Integration Request mapping template for the application/json Content-Type using Velocity Template Language (VTL) to format the payload and encode the data using $util.base64Encode().Answer
- Create an IAM execution role that allows the kinesis:PutRecords action, trust the apigateway.amazonaws.com service principal, and specify the role's ARN in the Credentials field of the API Gateway Integration Request.Answer
- CConfigure the API Gateway integration type as AWS Service with a Lambda Proxy integration, and set the request payload to be processed via Lambda.
- DAssociate the IAM execution role with an Amazon Cognito Identity Pool, and configure a Cognito User Pool Authorizer on the API method to handle the direct payload mapping.
- EEnable Request Validation on the API Gateway Method Request and configure a mapping template in the Method Response section to base64-encode the client payload.
Answer
Configure an Integration Request mapping template using VTL to base64-encode the payload, and create an IAM execution role with Kinesis PutRecords permissions configured in the Integration Request Credentials.
The correct solution involves utilizing API Gateway's direct 'AWS Service' integration with Amazon Kinesis. This requires an IAM execution role that allows the API Gateway service principal to call the Kinesis PutRecords action. Furthermore, because Kinesis requires payload data to be base64-encoded, an Integration Request mapping template using Velocity Template Language (VTL) and the utility function helper must be used to restructure the client's request payload into the format expected by Kinesis.
Step-by-Step Solution
Key Concept
AWS Service Direct Integration with Amazon API Gateway