Before you begin
- A CostGraph API key with the
pricing:readscope. Create one in Settings > API keys. Addfocus:readto price resources that already exist from your bill. - An Infracost API key, to price AWS, Azure, and Google Cloud resources. Without one, see Without an Infracost key.
Connect your Infracost key
In CostGraph, open Integrations, choose Infracost, and paste the API key your Infracost CLI already uses. Print it withinfracost configure get api_key.
Connecting a new key replaces the old one. You need to be an organization owner,
admin, or billing admin.
Point the CLI at CostGraph
Set two environment variables before you runinfracost. The value is your
CostGraph API key, not your Infracost key.
- CLI v0.10
- CLI v2
infracost breakdown as usual.
What changes
AWS, Azure, and Google Cloud prices come from Infracost with your key. Other providers come from CostGraph prices. Prices reflect what your bill shows you pay for each SKU over the last 30 days. SKUs you haven’t used yet show list price. Bill-rate adjustment applies to AWS. Azure and Google Cloud show list price.Price other providers
Infracost does not price every provider. CostGraph prices Terraform resources from providers it skips, and shows what the same machine costs elsewhere, at your account’s rates where CostGraph has your bill.Run it in GitHub Actions
The CostGraph Terraform cost action prices your plan and keeps one comment on the pull request, updated on every run. Store an API key from Settings > Account > API keys as the secretCOSTGRAPH_API_KEY.
plan-path, one per line, to review several Terraform projects in one comment. It also sets the outputs total-monthly-cost, previous-monthly-cost and diff-monthly-cost.
To keep the estimate as a file, set artifact-name: cost-estimate and download it from the workflow run, or read the estimate-path output in a later step. The file uses the Infracost JSON format, so Infracost’s own commands can read it.
To show what a pull request’s CI runs cost in a second comment, see Show CI cost on pull requests.
What the comment shows
- Monthly cost of every priced resource. For a plan that changes existing resources, the previous cost and the change are shown too.
- Same shape elsewhere, a table of cheaper alternatives for every priced server, with size (vCPU, memory, GPUs), monthly cost and savings. It covers AWS, Azure and Google Cloud compute (EC2, EKS node groups, Azure VMs, Compute Engine). Alternatives are on the same continent, run the same operating system, and compare spot with spot.
- Not priced, a list of resources the plan cannot price, each with a reason. They are not counted as $0.
AWS, Azure and Google Cloud
Connect your Infracost API key in CostGraph to price AWS, Azure and Google Cloud at your bill rates. Without it, CostGraph prices what its catalog covers and lists the rest under “Not priced”. The key stays in CostGraph, so the workflow only needsCOSTGRAPH_API_KEY.
Verified prices
Connect your AWS or Google Cloud billing export and CostGraph prices each line at what you paid for that product over the last 30 days. That includes your discounts and commitments. Lines priced from your bill are marked :white_check_mark: in the pull request comment and showbill in the CLI’s SOURCE column. Other lines use public list prices. Products you have not used yet are priced at list price until they appear on your bill.
Resources that already exist are priced at what they cost on your bill over the last 30 days, scaled to a month. Reserved instance and savings plan discounts are included. When a commitment covers the resource, the comment says which one. Resources that Terraform is creating, or changing in a way that changes their price, keep the estimate. This needs an API key with focus:read; without it the comment keeps the estimates and the job log says why. Outside GitHub Actions, pass the plan with --plan plan.json to costgraph cost output or costgraph cost comment github.
Run it in other CI systems
Install the CLI withuses: baselinehq/costgraph-action@v0 in GitHub Actions, or install the CostGraph CLI in any other CI system. Then create a plan file and run the commands:
To set up the Infracost CLI in your shell, run
eval "$(costgraph cost setup-infracost)". To keep the values in a file, run costgraph cost setup-infracost --write infracost.env, then set -a; . ./infracost.env; set +a.
Supported providers
- Hetzner Cloud: servers and volumes
- DigitalOcean: Droplets and volumes
- Linode (Akamai): instances, volumes, and managed MySQL and PostgreSQL
- Vultr: instances and block storage
- Scaleway: instances and block volumes
- STACKIT: servers, volumes, and PostgreSQL Flex
- OVHcloud: volumes
- Oracle Cloud: fixed-shape instances and block volumes
- IBM Cloud: VPC instances and volumes
- Alibaba Cloud: instances and disks
- UpCloud: servers and storage
- Civo: volumes
- Exoscale: instances and block storage volumes
Not priced by CostGraph
A resource that CostGraph cannot price is still listed, with the reason. For example, its size may only be known after apply. CostGraph does not count it as $0.Other providers for the same server
For priced servers, the output can show the same shape at other providers. Add--no-alternatives to turn this off.