Config file

An Infracost config file can be created in each of your Terraform project repos to specify how Infracost should be run. This has three main advantages over CLI flags:

  1. Not having to remember or specify flags for each run.
  2. Ability to run Infracost with multiple Terraform projects or workspaces, and combine them into the same breakdown or diff output.
  3. Enable multi-project or workspace runs in CI/CD integrations.


  1. Create an infracost.yml file in each of your Terraform project repos. Each project can have the parameters mentioned in the table below; you might find the following examples helpful.

    version: 0.1
    - path: path/to/my_terraform
    # other params
    - path: another/project
  2. Pass the file to the infracost breakdown or infracost diff using the --config-file option. This flag should not be confused with the --usage-file option that is used to define resource usage estimates.

pathPath to the Terraform directory or JSON/plan fileRequired
usage_filePath to Infracost usage file that specifies values for usage-based resourcesNot required
terraform_binaryUsed to change the path to the terraform binaryNot required, e.g. can be set to terragrunt or another path
terraform_plan_flagsFlags to pass to terraform plan with Terraform directory pathsNot required. Can be space delimited, e.g. -var-file=prod.tfvars -var-file=us-east.tfvars
terraform_workspaceUsed to set the Terraform workspaceNot required. Only set this for multi-workspace deployments, otherwise it might result in the Terraform error "workspaces not supported"
terraform_use_stateUse Terraform state instead of generating a plan, useful if you want to see the breakdown of the current Terraform state.Not required. Applicable when path is a Terraform directory. Can't be used with the diff command.
terraform_cloud_hostFor Terraform Enterprise users, used to override the default backend hostNot required
terraform_cloud_tokenFor Terraform Cloud/Enterprise users, set this to a Team API Token or User API Token so Infracost can use it to access the planNot required. If this environment variable is set, that'll be used for all projects instead of this parameter


version: 0.1
- path: examples/terraform
terraform_plan_flags: -var-file=prod.tfvars -var-file=us-east.tfvars
terraform_workspace: prod
- path: examples/terraform
terraform_plan_flags: -var-file=stage.tfvars
terraform_workspace: stage
- path: examples/terraform
terraform_workspace: dev

If your requirements cannot be satisfied with a config file, please create an issue so we can understand the use-case. Also consider using these bash scripts that demonstrate how Infracost commands can be combined.


Infracost configuration values are chosen in this order:

  1. CLI flags (run infracost --help to see them)
  2. Environment variables
  3. Config file