Google CloudCloud FunctionsServerless

google_cloudfunctions_function cost estimation

A 1st-gen serverless function. Priced per invocation plus compute time (GHz-seconds and GB-seconds), with a generous free tier and scale to zero.

A google_cloudfunctions_function is a 1st-generation event-driven serverless function. Like all functions-as-a-service, it scales to zero and bills only for what runs, across three usage dimensions plus egress.

Invocations bill at roughly $0.40 per million after the first 2 million free each month. Compute bills two ways simultaneously: CPU time in GHz-seconds (~$0.0000100 each) and memory time in GB-seconds (~$0.0000025 each), both metered for the duration each invocation runs at its configured CPU and memory. Outbound networking is charged per GB. The free tier (2M invocations, 400,000 GB-seconds, 200,000 GHz-seconds monthly) covers a lot of low-traffic functions entirely.

c3x prices Cloud Functions from the invocation count and compute-time figures you supply in c3x-usage.yml. Without usage input the standing cost is zero, which is correct for a scale-to-zero function. For new projects, the 2nd-gen google_cloudfunctions2_function (built on Cloud Run) is generally recommended, but 1st-gen remains widely deployed.

Terraform example

A minimal but realistic configuration that C3X can estimate.

resource "google_cloudfunctions_function" "thumbnail" {
  name        = "make-thumbnail"
  runtime     = "nodejs20"
  region      = "us-central1"

  available_memory_mb   = 256
  source_archive_bucket = google_storage_bucket.src.name
  source_archive_object = google_storage_bucket_object.zip.name
  trigger_http          = true
  entry_point           = "makeThumbnail"
}

Pricing dimensions

What you actually pay for when you provision google_cloudfunctions_function.

DimensionUnitWhat's being charged
Invocationsper millionEach function invocation after the first 2 million/month free. Usage-based.
$0.40 per million invocations
Compute time (GB-seconds)per GB-secondMemory allocated x duration. Free tier covers 400,000 GB-seconds/month. Usage-based.
$0.0000025/GB-second
Compute time (GHz-seconds)per GHz-secondCPU allocated x duration. Free tier covers 200,000 GHz-seconds/month. Usage-based.
$0.0000100/GHz-second
Outbound networkingper GBData egress from the function. Usage-based.

Sample C3X output

Example output from c3x estimate (12M invocations, light compute):

google_cloudfunctions_function.thumbnail
└─ Invocations (10M billable)   10  M-invocations    $4.00

OVERALL TOTAL                                        $4.00
(compute within free tier; egress usage-based)

Optimization tips

Common ways to reduce google_cloudfunctions_function cost without changing the workload.

Right-size memory, since it sets both meters

Proportional to over-allocation

Allocated memory drives the GB-second charge and the CPU allocation tied to it. Over-allocating memory for a function that doesn't need it inflates compute cost. Profile and set the smallest tier that works.

Reduce execution time

Compute-time proportional

Compute bills per second of runtime. Trimming cold-start work, reusing connections, and avoiding synchronous waits lowers GB-second and GHz-second charges directly.

Stay within the free tier where possible

Up to 100% for low traffic

2M invocations and generous compute are free monthly. Many low-traffic utility functions cost nothing. Consolidate rarely-used logic rather than spreading it across many functions.

FAQ

How does c3x estimate Cloud Functions cost?

It prices invocations and compute time (GB-seconds and GHz-seconds) from the figures you supply in c3x-usage.yml, applying the free-tier allowances first. With no usage supplied, the standing cost is zero.

Why does an idle function cost nothing?

Cloud Functions scale to zero and bill only per invocation and execution time. A deployed function with no traffic incurs no charge.

Should I use 1st gen or 2nd gen?

For new projects, 2nd gen (google_cloudfunctions2_function, built on Cloud Run) is generally recommended for longer timeouts, concurrency, and traffic splitting. 1st gen remains common and is priced on the invocation-plus-compute model described here.

What's usually the biggest cost driver?

For most functions it's compute time (GB-seconds), driven by allocated memory times execution duration. High-frequency functions can also accrue meaningful invocation charges. Egress matters only for data-heavy responses.

Is the trigger source billed here?

No. If the function is triggered by Pub/Sub, Cloud Storage, or HTTP, those sources bill on their own resources. c3x estimates them separately if present in your Terraform.

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 google_cloudfunctions_function.