Soru

Zorluk: ZorAPI Development and Integration with Amazon API Gateway

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.)

  1. 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().Cevap
  2. 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.Cevap
  3. C
    Configure the API Gateway integration type as AWS Service with a Lambda Proxy integration, and set the request payload to be processed via Lambda.
  4. D
    Associate 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.
  5. E
    Enable Request Validation on the API Gateway Method Request and configure a mapping template in the Method Response section to base64-encode the client payload.

Cevap

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.

Adım Adım Çözüm

1
Configure the API Gateway Method to use the 'AWS Service' integration type pointing to the Kinesis service and PutRecords action.
Establishes a direct connection between API Gateway and Amazon Kinesis without intermediate compute resources.
Eliminating Lambda reduces costs and cold-start latencies.
2
Create an IAM role allowing 'kinesis:PutRecords' with a trust relationship for 'apigateway.amazonaws.com' and paste its ARN in the Credentials field.
Grants API Gateway the required authorization to write data into the target Kinesis data stream.
API Gateway needs explicit execution permissions to access downstream AWS resources.
3
Add an Integration Request mapping template for 'application/json' that maps client data to Kinesis format using VTL helper functions.
Formats the payload to the required Kinesis schema and encodes the telemetry data using the built-in base64 utility.
The Kinesis API expects record data payloads to be base64-encoded strings.

Anahtar Kavram

AWS Service Direct Integration with Amazon API Gateway
Bu soruyu puanla