I created a dynamodb table and associated a lambda function which will be triggered on every write
but then I wrote 20 fields but the lambda was triggered only twice
is AWS Lambda incapable of handling 20 invocations? What is wrong here?
AWS Lambda polls Dynamodbstream in a fixed time interval and triggers your Lambda function by passing all the records as a list in one lambda call. You can however control the max size using batchSize while creating your lambda function.
Here is the sample node.js call to iterate over list of records
exports.lambda_handler = function(event, context, callback) {
console.log(JSON.stringify(event, null, 2));
event.Records.forEach(function(record) {
console.log(record.eventID);
console.log(record.eventName);
console.log('DynamoDB Record: %j', record.dynamodb);
});
callback(null, "message");
};
See https://docs.aws.amazon.com/lambda/latest/dg/with-ddb-create-package.html for sample code in other languages