A developer is building an IoT application where temperature sensors send data to an Amazon Kinesis Data Stream. An AWS Lambda function is configured to process the stream in batches and write the processed records to a database inside a private subnet of a VPC. During testing, the developer notices two issues: some shards are heavily throttled with ProvisionedThroughputExceededException errors, and the Lambda function cannot access the Kinesis stream endpoints to read the records. How should the developer resolve both the stream throttling and the Lambda connectivity issues?
- Select the unique device ID as the Kinesis partition key to distribute data evenly across shards, and configure interface VPC endpoints for Kinesis in the VPC to allow the Lambda function to access the stream.Answer
- BSelect the city where the device is located as the Kinesis partition key to group the data, and configure a NAT Gateway in the public subnet to allow the Lambda function to access the stream.
- CSelect the unique device ID as the Kinesis partition key, and modify the Lambda function's IAM role trust policy to allow direct service access to the VPC resources while increasing the Lambda function timeout to handle network retries.
- DSelect a static string as the partition key to guarantee ordering across all shards, and ensure the Lambda function is placed in the private subnet with no NAT Gateway or VPC endpoints to prevent external access.
Answer
Select the unique device ID as the Kinesis partition key to distribute data evenly across shards, and configure interface VPC endpoints for Kinesis in the VPC to allow the Lambda function to access the stream.
The correct option addresses both the data distribution and network access requirements. First, using the unique device ID as the partition key provides high entropy, which distributes the data evenly across Kinesis shards, preventing hot shards and ProvisionedThroughputExceededException errors. Second, deploying interface VPC endpoints (AWS PrivateLink) inside the VPC allows the Lambda function in the private subnet to securely communicate with Kinesis endpoints without routing traffic over the public internet.
Step-by-Step Solution
Key Concept
Selecting high-entropy partition keys for Amazon Kinesis to avoid hot shards, and using VPC endpoints for private resource connectivity.