aws_lambda_event_source_mapping cost estimation
An event source mapping is free. It connects a stream or queue to a Lambda function, and the cost is the invocations it drives plus any polling charges on the source.
An aws_lambda_event_source_mapping wires a poll-based source (an SQS queue, a Kinesis or DynamoDB stream, an MSK or Kafka topic) to a Lambda function, so Lambda reads batches from the source and invokes the function on each. The mapping resource itself has no charge. What it does is turn events into Lambda invocations, and those invocations are where the cost lands.
Every batch the mapping delivers is a Lambda invocation billed per request and per GB-second of duration. Batch settings are the main lever: a larger batch_size and a batch window mean more records processed per invocation, so fewer invocations and lower request cost for the same volume. A mapping configured for batch_size 1 on a busy queue invokes the function once per message, which is the most expensive way to run it.
The polling side can add cost too. SQS polling by the mapping counts as SQS requests, and Kinesis or DynamoDB stream polling consumes read throughput on the source. High parallelization (parallelization_factor on streams, or many concurrent SQS batches) multiplies function concurrency and therefore duration cost. c3x prices the target function by its memory, duration, and the invocation volume the mapping is likely to produce, and treats the mapping as the free connector it is.
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "aws_lambda_event_source_mapping" "queue" {
event_source_arn = aws_sqs_queue.jobs.arn
function_name = aws_lambda_function.worker.arn
batch_size = 10
scaling_config {
maximum_concurrency = 5
}
}Pricing dimensions
What you actually pay for when you provision aws_lambda_event_source_mapping.
| Dimension | Unit | What's being charged |
|---|---|---|
| Event source mapping | free | The mapping that connects the source to the function has no charge. $0 |
| Function invocations | per 1M requests + per GB-second | Each delivered batch invokes the function, billed per request and by duration. $0.20 per 1M requests |
| Source polling | per request / per shard-hour | SQS polling counts as SQS requests; stream polling consumes read throughput on Kinesis or DynamoDB. SQS: $0.40 per 1M requests |
Optimization tips
Common ways to reduce aws_lambda_event_source_mapping cost without changing the workload.
Increase batch_size
Fewer invocations for the same throughputProcessing more records per invocation cuts the number of Lambda invocations for the same volume. A larger batch_size directly lowers request-count cost on busy sources.
Add a batching window
Setting maximum_batching_window_in_seconds lets Lambda accumulate records before invoking, filling batches on lower-volume sources and reducing invocation count.
Bound concurrency
Set maximum_concurrency (SQS) or a modest parallelization_factor (streams) so a burst does not fan out into far more concurrent, duration-billed invocations than you intend.
FAQ
Does a Lambda event source mapping cost money?
No. The mapping is free. You pay for the Lambda invocations it triggers, billed per request and per GB-second, plus the polling requests or stream read throughput it consumes on the source.
How do I reduce the cost of an event source mapping?
Raise batch_size and add a batching window so more records are processed per invocation, which reduces the number of billed Lambda invocations for the same volume of events.
Does polling an SQS queue with Lambda cost extra?
Yes, a little. The mapping polls the queue, and each poll counts as an SQS request. Larger batches and a batching window reduce polls, and the dominant cost remains the Lambda invocations themselves.
Related resources
Estimate this resource in your own Terraform
Free, open source, no API key. C3X parses your Terraform and shows line-item cost for every resource, including aws_lambda_event_source_mapping.