Choose a guide
- Terraform cost on pull requests prices a Terraform plan, combines it with an Infracost estimate, and posts one comment. Its other CI systems section shows the CLI commands outside GitHub Actions.
- CI cost on pull requests posts what a pull request’s GitHub Actions runs have cost.
COSTGRAPH_API_KEY. Refer to Use the key in a script or CI.
Requirements
For Terraform pricing, use a saved session or an API key withpricing:read. CI cost comments and existing-resource lookups through --plan need focus:read.
GitHub comments also need a token with permission to comment on the pull request. Pass it through GITHUB_TOKEN or --github-token. Set --github-api-url for GitHub Enterprise Server.
Create the plan file
costgraph cost breakdown and costgraph cost diff read the JSON form of a Terraform plan.
--format infracost-json writes Infracost’s format, so costgraph cost output can combine the result with an Infracost estimate. --out-file writes the result to a file instead of standard output.
costgraph cost breakdown also looks up the same machine shape at other providers through the CostGraph Pricing API. The CLI sends your CostGraph credential to the Pricing API address in api.pricing_url, https://pricing.baselinehq.cloud by default. Add --no-alternatives to skip that lookup.
Pull request comments
Choose the command for either Terraform estimates or CI execution cost.Preview CI cost
Both comment commands edit the comment they posted earlier on the same pull request.--behavior new posts a new comment each time.
costgraph cost ci comment github supports --dry-run, which prints the comment instead of posting it.
Preview Terraform estimates
costgraph cost comment github has no dry-run option. Preview its content with costgraph cost output, --format github-comment, and the same --path and --plan files.
Command reference
Commands are shown without thecostgraph prefix. Add --help for the complete flag list.
Terraform plan estimates
Run each command with thecostgraph prefix.
Combines CostGraph and Infracost estimates. No CostGraph credential needed without
--plan. With --plan, existing-resource lookups need focus:read.Prints environment variables for using CostGraph prices with Infracost. No existing credential required.
GitHub pull request comments
Both commands need a GitHub token with permission to comment on the pull request.Posts or updates the Terraform estimate comment. No dry-run option.
--plan lookups need focus:read.Posts or updates CI cost. Requires a session or key with
focus:read. Use --dry-run to preview.Estimate output flags
These flags control Terraform pricing results.Selects the command’s input plan or estimate files. Check command help for its accepted input shape.
Selects the command’s output format.
breakdown supports infracost-json; output supports github-comment.