aws_ lambda_ function cost estimation
A serverless function billed by request count and execution duration. Free tier covers 1M requests and 400,000 GB-seconds per month.
An aws_
Requests are billed at a flat per-invocation rate. The first million requests per month are free at the account level (across all functions); beyond that, each invocation costs a tiny but cumulative amount.
Duration is the more interesting dimension. Lambda bills in GB-seconds, calculated as the function's memory size (in GB) multiplied by execution time (rounded up to the nearest millisecond). A function with 512 MB memory that runs for 200 ms is billed as 0.5 GB × 0.2 s = 0.1 GB-seconds. The same function with 1 GB memory that runs for 100 ms (because more memory often means more CPU) is also 0.1 GB-seconds but finishes twice as fast. The free tier covers 400,000 GB-seconds per month.
Because Lambda's cost is usage-based by definition, c3x cannot estimate it from the Terraform configuration alone. The Terraform resource sets the memory and timeout, but the actual monthly invocation count and average duration come from a c3x-usage.yml file. Without that file, c3x reports Lambda costs as "depends on usage" and shows the per-unit rate.
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "aws_lambda_function" "image_processor" {
function_name = "image-processor"
role = aws_iam_role.lambda_exec.arn
handler = "index.handler"
runtime = "nodejs20.x"
memory_size = 1024
timeout = 30
filename = "lambda.zip"
source_code_hash = filebase64sha256("lambda.zip")
}Pricing dimensions
What you actually pay for when you provision aws_.
| Dimension | Unit | What's being charged |
|---|---|---|
| Requests | per request | Flat per-invocation rate. First 1M requests per month free at the account level. $0.20 per 1M requests beyond the free tier |
| Compute duration | per GB-second | Memory size (GB) multiplied by execution time, rounded up to the nearest millisecond. First 400,000 GB-seconds per month free. $0.0000166667/GB-second for x86_64; $0.0000133334/GB-second for arm64 (Graviton) |
| Provisioned concurrency | per GB-second | If aws_ |
| Data transfer out | per GB | Bytes returned from Lambda to clients outside AWS. Standard AWS egress rates apply. |
Sample C3X output
With c3x-usage.yml specifying 10M monthly requests and 200 ms average duration:
aws_lambda_function.image_processor
├─ Requests 9.0M (after free tier) $1.80
└─ Duration 1.6M GB-sec $26.67
OVERALL TOTAL $28.47Optimization tips
Common ways to reduce aws_ cost without changing the workload.
Switch to arm64 (Graviton)
20%Set architectures = ["arm64"] on the function. Graviton is 20% cheaper per GB-second than x86_
Right-size memory using power tuning
Workload-dependent, often 30-60%More memory often means a faster runtime, which can lower total GB-seconds even though the per-second rate is higher. Run the AWS Lambda Power Tuning tool to find the sweet spot for each function.
Switch from on-demand to provisioned concurrency for hot paths
10-40% on high-volume functionsIf a function fires more than ~1M times per hour and cold starts hurt, provisioned concurrency is cheaper per request than on-demand. For low-volume functions, stay on-demand.
Cache external calls inside the function handler
Latency-drivenA function that fetches the same secret or config on every invocation pays duration cost for that fetch. Cache outside the handler (in the module scope) and the fetch happens once per warm worker.
FAQ
Why does c3x show Lambda cost as zero or 'depends on usage'?
Lambda is usage-based. Without a c3x-usage.yml file specifying expected requests and duration, c3x cannot produce a meaningful number. Add the function under monthly_
Does c3x handle Lambda Layers or container images differently?
No. Layers and container images affect cold-start time and storage, but Lambda's billed cost is still just requests and GB-seconds. Container images stored in ECR incur a separate aws_
What about provisioned concurrency?
If you also define an aws_
Does c3x estimate EventBridge or API Gateway invocations?
Those are separate resources (aws_
Can I model Lambda Free Tier in c3x?
Yes. c3x deducts 1M requests and 400,000 GB-seconds from the first Lambda function's monthly cost in each estimate. If you have many functions, the free tier applies once per account, so c3x's per-function estimate is slightly conservative.
Related resources
More AWS resources
Further reading
- Migrating to ARM for cost: a staged playbook with real numbers
ARM based instances price 10 to 20 percent below their x86 equivalents and often deliver better price performance than the headline rate suggests. Here is the staged migration playbook, the workloads that port cleanly, and the ones that do not.
- AWS CDK cost estimation: price the synthesized CloudFormation
CDK synthesizes to CloudFormation, so you estimate cost from the synth output, run cdk synth, then price the templates in cdk.out. Here's how to get a cost per stack before cdk deploy, locally and in CI.
- AWS Free Tier explained: what's free in 2026
Three categories of AWS Free Tier (12-months-free, always-free, trial offers) with the actual limits for each service. What stays free forever, what expires, what surprises new accounts.
- AWS IoT Core cost: messages, connection minutes, and rules
IoT Core bills connectivity per million connection-minutes, messaging per million messages, and rules-engine actions, plus device shadow and registry operations. Chatty devices and heavy rule fan-out drive the bill. Here is the model.
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_.