You have a Lambda function triggered by a DynamoDB stream with batch size set to 5. The stream receives 7 new records at once. How many times will the Lambda function be invoked?
Think about how batch size controls the maximum number of records per invocation.
The batch size limits the number of records per Lambda invocation. With 7 records and batch size 5, Lambda is invoked twice: first with 5 records, then with 2.
You want to process DynamoDB stream records with a Lambda function ensuring each record is processed exactly once, even if retries happen. Which architectural choice helps achieve this?
Consider how retries can cause duplicate processing and how to handle it.
Lambda retries can cause the same record to be processed multiple times. Implementing idempotent logic in the Lambda function ensures processing is safe and exactly-once.
Given this AWS CLI command to create an event source mapping for a Lambda function triggered by a DynamoDB stream, what is the effect of the --starting-position TRIM_HORIZON parameter?
aws lambda create-event-source-mapping \ --function-name MyLambdaFunction \ --event-source-arn arn:aws:dynamodb:us-east-1:123456789012:table/MyTable/stream/2023-01-01T00:00:00.000 \ --starting-position TRIM_HORIZON \ --batch-size 10
Think about what 'TRIM_HORIZON' means in stream processing.
TRIM_HORIZON means the Lambda starts reading from the oldest record available in the stream, processing all existing records.
Which IAM permission is required for a Lambda function to read records from a DynamoDB stream?
Consider what action allows reading stream records.
The permission dynamodb:GetRecords allows Lambda to read records from the DynamoDB stream.
Your Lambda function processes batches of DynamoDB stream records. If processing one record in the batch fails, what is the best practice to avoid losing other successfully processed records?
Think about how to handle failures without reprocessing successful records.
Using the partial batch response feature lets Lambda acknowledge successful records and retry only failed ones, avoiding duplicate processing of successful records.