AWS Cloud Architecture•Part 3: Compute, Containers & Serverless (21 - 35)
Lambda Event Source Mapping (ESM).
In Simple Words: An AWS-managed internal poller that reads records in batches from queues or streams (SQS, Kinesis, DynamoDB Streams) and synchronously invokes your Lambda function with the batch.
hcl
# Event Source Mapping connecting SQS queue to Lambda:
resource "aws_lambda_event_source_mapping" "sqs_trigger" {
event_source_arn = aws_sqs_queue.orders_queue.arn
function_name = aws_lambda_function.order_processor.arn
batch_size = 10
maximum_batching_window_in_seconds = 5
}