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.- Homebrew
- Script
- Manual
brew upgrade costgraph.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
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.--callback-port. You can also set api.callback_port in the CLI configuration.
Check the saved session
The following command reports the saved session.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.* 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.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 thecostgraph_tenant data source. Provider 0.3.0 and later resolves the ID for your resources.
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.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 asCOSTGRAPH_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 thecostgraph prefix. Add --help for the complete flag list.
Authentication commands
Run each command with thecostgraph prefix.
Reports the configured credential without contacting CostGraph. It does not verify scopes or access.
Tenant commands
Choose which tenant your saved session uses.Sign-in flags
Pass these flags tocostgraph auth login.