google_compute_instance cost estimation
A Google Compute Engine VM. Priced per second by machine type, region, and license. Sustained-use discounts apply automatically.
A google_compute_instance is a Compute Engine VM. GCP pricing differs from AWS and Azure in a few important ways.
First, machine types fall into families (e2, n2, n2d, c2, c3, t2d, etc.) priced by predefined size or by custom CPU+memory configuration. Custom machine types let you pay only for the exact CPU and memory you need; this is unique to GCP and often the cheapest path.
Second, sustained-use discounts (SUD) are automatic. A VM that runs more than 25% of the month gets a tiered discount that climbs to 30% off if it runs the entire month. No commitment required. c3x applies these automatically when estimating monthly cost.
Third, Committed Use Discounts (CUD) require a 1-year or 3-year commitment but cut prices by 37% to 70%. Set purchaseOption: 'cud_1yr' or 'cud_3yr' in c3x-usage.yml.
Persistent Disks (boot and additional) are billed per GB-month at rates that depend on the disk type (pd-standard, pd-balanced, pd-ssd, hyperdisk). Egress to the internet is usage-based and modeled via c3x-usage.yml.
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "google_compute_instance" "api" {
name = "api-server"
machine_type = "e2-standard-4"
zone = "us-central1-a"
boot_disk {
initialize_params {
image = "debian-cloud/debian-12"
size = 100
type = "pd-balanced"
}
}
network_interface {
network = "default"
access_config {}
}
}Pricing dimensions
What you actually pay for when you provision google_compute_instance.
| Dimension | Unit | What's being charged |
|---|---|---|
| Instance hours | per hour | On-demand rate for the machine type. Sustained-use discounts apply automatically to monthly estimates. $0.134/hour for e2-standard-4 in us-central1 |
| Boot disk | per GB-month | Provisioned size of the boot disk. Type (pd-standard, pd-balanced, pd-ssd, hyperdisk) determines the per-GB rate. $0.10/GB-month for pd-balanced in us-central1 |
| Additional persistent disks | per GB-month | Same per-GB rate as the boot disk. Hyperdisk has separate per-IOPS and per-MBps charges. |
| Network egress to internet | per GB | Bytes leaving Google's network to the public internet. First 200 GB/month free at the project level. Premium tier (default) and Standard tier have different rates. |
Optimization tips
Common ways to reduce google_compute_instance cost without changing the workload.
Use E2 family for general workloads
20-30%The E2 family is GCP's cost-optimized general-purpose family, typically 20-30% cheaper than N1/N2 at the same vCPU/memory ratio. Right default for web apps, APIs, and most backends.
Use custom machine types instead of predefined
Workload-dependent, 10-20%If your workload needs an unusual CPU-to-memory ratio (e.g., 2 vCPU and 16 GB RAM), a custom machine type can be cheaper than the nearest predefined size that overprovisions one dimension.
Commit to 1-year or 3-year usage
37-70%Committed Use Discounts cut prices by 37% (1-year) to 70% (3-year). Model with purchaseOption: 'cud_1yr' or 'cud_3yr' in c3x-usage.yml.
Switch to Spot VMs for fault-tolerant workloads
60-91%Spot VMs cost 60-91% less than on-demand. They can be preempted with 30 seconds notice. Right for batch jobs, CI runners, and any work that tolerates interruption.
FAQ
Does c3x apply Sustained Use Discounts?
Yes. SUDs are applied automatically when c3x calculates monthly cost (730 hours of usage), reducing on-demand pricing by up to 30%. The output shows the discounted rate.
How does c3x handle custom machine types?
c3x reads machine_type. For custom types (e.g., 'custom-4-16384'), it parses the CPU and memory dimensions and uses GCP's per-vCPU and per-GB-RAM rates.
What about Spot VMs?
Set scheduling { provisioning_model = "SPOT" } on the resource. c3x detects this and uses the Spot pricing tier in its estimate.
Does c3x include premium tier vs standard tier networking?
Egress pricing differs between Premium and Standard network tiers. c3x defaults to Premium (the GCP default). Override via c3x-usage.yml if your VMs use Standard tier.
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_compute_instance.