Skip to main content
Install the costgraph command, sign in through your browser, and confirm which tenant your commands use. The CLI runs on macOS and Linux.

Install

Choose one installation method. Homebrew and the install script both install the latest release.
To update later, run brew upgrade costgraph.
Check the installed version.
The output names the version, the commit it was built from, and the build time.
If the version is older than the release you installed, another costgraph binary comes earlier on your PATH. Run which -a costgraph to list every copy. Remove the old copy or put the new one first.

Sign in

Signing in creates a saved session for one tenant. The CLI stores it in ~/.config/costgraph/credentials.toml and uses it for later commands. The browser must run on the same machine as the CLI. CostGraph returns to a local callback address, http://localhost:9093/callback by default. On a machine without a browser, such as a CI runner, use an API key instead.
1

Start the sign-in

The CLI opens CostGraph in your browser and prints the same address. If the browser doesn’t open, copy the address into a browser on the same machine.
2

Approve the CLI

Sign in with your usual method, including single sign-on or Google. Choose the tenant for this session and approve the CLI.To preselect a tenant, add --tenant with its name or ID, such as costgraph auth login --tenant Production. Without it, CostGraph preselects the tenant that is active in your dashboard.
3

Confirm the result

The terminal reports your account, organization, role, and tenant, followed by the session file.
If you passed --tenant and chose a different tenant in the browser, the CLI warns that you signed in to another tenant.
If port 9093 is in use, pass another port with --callback-port. You can also set api.callback_port in the CLI configuration.

Check the saved session

The following command reports the saved session.
The output shows the sign-in method, your account, the API address, the tenant ID, and when the access token expires. costgraph auth status reads the saved session file. It doesn’t contact CostGraph, so it doesn’t prove that the session still works or list the permissions of a credential.

Choose a tenant

A tenant holds one set of cost data in your organization. Each saved session is bound to one tenant, and every command you run uses that tenant. List the tenants your account can use.
The table marks the session’s tenant with * and shows each tenant’s name and ID.

Switch tenants

Switch the session to another tenant by name or ID. Names match without regard to case.
Switching signs you in again with that tenant preselected. If you already approved the CLI for that tenant, the browser returns immediately. Run costgraph tenant use without a name to pick from a list in your terminal. Scripts and -o json runs must pass the name or ID.

Use a tenant in Terraform

Use the tenant’s name with the costgraph_tenant data source. Provider 0.3.0 and later resolves the ID for your resources.
Reference data.costgraph_tenant.production.id wherever a resource needs tenant_id. Names match exactly, including capitalization.

Sign out

Signing out deletes the saved session file on this machine. It doesn’t revoke the session in CostGraph.
The CLI prefers a saved session over an API key. Sign out before you run commands with an API key on the same machine. Refer to Credentials for how the CLI chooses one.

Use the CLI in CI

A CI job can’t complete the browser sign-in. Give the job an API key that you created and approved earlier, and expose it as COSTGRAPH_API_KEY. Refer to Use the key in a script or CI. In GitHub Actions, the CostGraph actions install the CLI for you.

CLI integration guides

The following guides run the CLI in pull request checks:

Command reference

Commands are shown without the costgraph prefix. Add --help for the complete flag list.

Authentication commands

Run each command with the costgraph prefix.
command
Opens browser sign-in and saves a session for one tenant.
command
Reports the configured credential without contacting CostGraph. It does not verify scopes or access.
command
Deletes the saved session file. It does not revoke the session in CostGraph.

Tenant commands

Choose which tenant your saved session uses.
command
Lists accessible tenant names and UUIDs. Accepts a session or an API key. Alias tenant ls.
command
Signs in again with that tenant preselected. Without an argument, opens a terminal picker.

Sign-in flags

Pass these flags to costgraph auth login.
string
Preselects a tenant by name or UUID.
integer
Sets the local browser callback port. Pass a nonzero port to override the default.