google-cloud-pricing-cost-calculator icon indicating copy to clipboard operation
google-cloud-pricing-cost-calculator copied to clipboard

πŸ’Έ Calculate estimated monthly costs of Google Cloud Platform products and resources via YAML files and CLI program (Linux, macOS, Windows)

Google Cloud Platform Pricing and Cost Calculator

CI GitHub Subreddit subscribers

Calculate estimated monthly costs of Google Cloud Platform products and resources. Optimized for DevOps, architects and engineers to quickly see a cost breakdown and compare different options upfront:

  • Mapping of resource usage is done in easy to learn YAML usage files
  • Price information is read from a local file
  • Calculation is done via gcosts CLI program
  • Calculated costs are saved in CSV files

Full control and no disclosure of any information and costs to third parties. Everything tested and matched against the actual invoice in large Google Cloud migration projects.

Screenshot: YAML usage file, gcosts and CSV costs file

☁️ Supported resources

The cost of a resource is calculated by multiplying its price by its usage.

πŸ’‘ Google Cloud Free Program
Free tiers and free trial (90-day, $300), which are usually not a significant part of cloud costs, are ignored. For example: 1x free non-preemptible e2-micro VM instance per month, free NAT for 32 VMs, 30 GB-months standard persistent disk, 1 GB network egress and everything else are not taken into account.

Resources that gcosts supports, and Google charges for:

πŸ–₯️ Compute Engine Instances
  • [x] All machine types are supported
    • [x] Cost-optimized (E2, F1, G1)
    • [x] Balanced (N1, N2, N2D)
    • [x] Scale-out optimized (Tau T2D and T2A)
    • [x] Memory-optimized (M1, M2)
    • [x] Compute optimized (C2, C2D)
    • [x] Accelerator optimized (A2)
  • [x] Sustained use discounts (SUD) are applied to monthly costs
  • [x] 1 year and 3 year committed use discounts (CUD) are supported
  • [x] Paid "premium" operating system licenses (paid images) are supported
    • [x] SUSE Linux Enterprise Server
    • [x] SLES for SAP (1y and 3y committed use discounts (CUD) are also supported)
    • [x] Red Hat Enterprise Linux
    • [x] RHEL for SAP
    • [x] Windows Server
  • [x] Custom machine types are supported (have to be created manually)
  • [ ] Spot and sole-tenant VMs are not supported
πŸ’Ύ Compute Engine Disks
  • [x] All persistent disk (PD) types are supported
    • [x] Zonal persistent disk
    • [x] Regional persistent disk
    • [x] Local SSD
πŸͺ£ Cloud Storage
  • [x] All storage classes and location types are supported
    • [x] region
    • [x] dual-region
    • [x] multi-region
πŸš‡ Hybrid Connectivity
  • [x] VPN tunnel
  • [ ] Interconnect is currently not calculated
πŸ”— Cloud NAT
  • [x] NAT gateway
  • [x] Data processing (both egress and ingress)
🀹 Cloud Load Balancing
  • [x] Forwarding rules
  • [x] Ingress data processed by load balancer
🚦 Cloud Monitoring (Operations Suite)
  • [x] Monitoring data
πŸ•ΈοΈ Network
  • [x] Premium Tier internet egress
    • [x] Worldwide destinations (excluding China & Australia, but including Hong Kong)
    • [x] China destinations (excluding Hong Kong)
    • [x] Australia destinations
πŸ—οΈ TODO

The following services are not currently supported, but are on the TODO list:

  • [ ] BigQuery
  • [ ] Cloud SQL

Please suggest other resources worth covering by upvoting existing issue or opening new issue.

πŸ§‘β€πŸ« Start the interactive tutorial

This guide is available as an interactive Cloud Shell tutorial. To get started, please click the following button:

Open in Cloud Shell

πŸƒ Quick start

1. Get gcosts program

Linux

Debian/Ubuntu or Google Cloud Shell (x86_64)

Download the executable gcosts Linux CLI program:

curl -OL "https://github.com/Cyclenerd/google-cloud-pricing-cost-calculator/releases/latest/download/gcosts" && \
chmod +x gcosts

Execute gcosts:

./gcosts --help

If you using another Linux or UNIX operating system, please see the Development section.

Windows

Microsoft Windows (x86_64)

Download the executable gcosts.exe Windows CLI program:

Invoke-WebRequest -Uri "https://github.com/Cyclenerd/google-cloud-pricing-cost-calculator/releases/latest/download/gcosts.exe" -OutFile "gcosts.exe"

Execute gcosts.exe:

.\gcosts.exe --help

2. Download price information

Linux

Download the latest and tested price information file pricing.yml:

curl -L "https://github.com/Cyclenerd/google-cloud-pricing-cost-calculator/raw/master/pricing.yml" \
     -o "pricing.yml"
Windows

Download the latest and tested price information file pricing.yml:

Invoke-WebRequest -Uri "https://github.com/Cyclenerd/google-cloud-pricing-cost-calculator/raw/master/pricing.yml" -OutFile "pricing.yml"

3. Run it

Create your first YAML usage file (usage.yml):

region: europe-west4
project: my-first-project
instances:
  - name: app-server
    type: e2-standard-8
    os: rhel
    commitment: 3
    disks:
      - name: disk-boot
        type: ssd
        data: 75

Execute the CLI program:

Linux

Execute gcosts:

./gcosts
Windows

Execute gcosts.exe:

.\gcosts.exe

All YAML usage files (*.yml) of the current directory are imported and the costs of the resources are calculated:

Two CSV (semicolon) files with the costs are created:

  1. COSTS.csv : Costs for resources
  2. TOTALS.csv : Total costs per name, resource, project, region and file

You can import the CSV files with MS Excel, LibreOffice or Google Sheets.

4. Get familiar

Continue to familiarize yourself with the options. The following documentations are prepared for this purpose:

  • Create usage files
  • Build pricing information file

πŸ€“ Linux Tip

Add gcosts to your Bash aliases with absolute pathnames. You can then execute gcosts anywhere.

Alias (~/.bash_aliases):

alias gcosts='/your-pathname/gcosts -pricing=/your-pathname/pricing.yml'

πŸ§‘β€πŸ’» Development

If you want to modify the Perl scripts or prefer to run the uncomplicated Perl scripts (gcosts.pl, skus.pl, mapping.pl, pricing.pl) and create the price information yourself, the following requirements are needed.

Open in Gitpod

Perl 5 is already installed on many Linux (Debian/Ubuntu, RedHat, SUSE) and UNIX (macOS, FreeBSD) operating systems. For MS Windows you can download and install Strawberry Perl.

Requirements

Debian/Ubuntu:

sudo apt update && \
sudo apt install \
	libapp-options-perl \
	libwww-perl \
	libjson-xs-perl \
	libyaml-libyaml-perl \
	libdbd-csv-perl \
	libdbd-sqlite3-perl

Or install Perl modules with cpanminus:

cpan App::cpanminus && \
cpanm --installdeps .

Execute gcosts.pl:

perl gcosts.pl --help

❀️ Contributing

Have a patch that will benefit this project? Awesome! Follow these steps to have it accepted.

  1. Please read how to contribute.
  2. Fork this Git repository and make your changes.
  3. Create a Pull Request.
  4. Incorporate review feedback to your changes.
  5. Accepted!

πŸ“œ License

All files in this repository are under the Apache License, Version 2.0 unless noted otherwise.

Please note:

  • No warranty
  • No official Google product