Skip to content

cost_estimation

The cost_estimation configuration can automatically provide cost estimates on each pull request that Terrateam runs a plan operation against. A comment will be placed alongside plan output showing the monthly spend change for the dirspace.

cost_estimation:
enabled: true
provider: infracost
currency: USD
KeyTypeDescription
enabledbooleanSpecifies whether cost estimation is enabled. Default is true.
providerstringSpecifies the provider for cost estimation. Default is infracost.
currencystringSpecifies the currency for cost estimation. Default is USD.

If an Infracost API key is configured as a GitHub Actions Secret, then Terrateam will use the official Infracost public API endpoint. To set your Infracost API Key as a GitHub Actions Secret:

  1. Export your Terraform organization/repo combination as an environment variable. For example:
export REPO="OWNER/REPO"
  1. Create the Infracost API Key GitHub Secret:
gh secret --repo "$REPO" set INFRACOST_API_KEY

Terrateam supports the following Infracost environment variables:

NameDescription
INFRACOST_API_KEYUser’s Infracost API key. Sign up and navigate to the Org Settings page to get your free Infracost API key.
INFRACOST_CURRENCYAn ISO 4217 currency code to report results. The value in the repository configuration takes precedence.
INFRACOST_CONFIG_FILEPath to a custom Infracost config file to use instead of the one Terrateam generates. Relative paths are resolved from the repository root.

Enable Cost Estimation with Default Settings

Section titled “Enable Cost Estimation with Default Settings”
cost_estimation:
enabled: true

This configuration will enable cost estimation using the default provider (Infracost) and currency (USD).

cost_estimation:
enabled: false

This configuration will disable cost estimation.

cost_estimation:
enabled: true
currency: EUR

This configuration will enable cost estimation and report results in Euros (EUR).

By default Terrateam generates an Infracost config file listing the directories and workspaces being run. To use your own instead, set the INFRACOST_CONFIG_FILE environment variable to its path. The value can be set with an env hook:

hooks:
plan:
pre:
- type: env
name: INFRACOST_CONFIG_FILE
cmd: ["echo", "infracost.yml"]

The path is relative to the repository root (or absolute). If the file does not exist on a given branch — for example the base branch used to compute the previous cost — Terrateam falls back to the config it generates.