Terraform Cloud/Enterprise
The environment variables mentioned in this page can also be set in an Infracost config file.
#
Terraform Cloud usersThis section is only applicable for Terraform Cloud users.
Running Infracost locally requires no additional steps as your Terraform CLI config file is used to access the plan.
When running Infracost on CI/CD systems, you should either:
- Set the
INFRACOST_TERRAFORM_CLOUD_TOKEN
environment variable to a Team API Token or User API Token. - Set the Terraform environment variable
TF_CLI_CONFIG_FILE
to the absolute path of your Terraform CLI config file.
#
Terraform Enterprise usersWhen running Infracost locally or on CI/CD systems, you should set both of the following environment variables:
INFRACOST_TERRAFORM_CLOUD_TOKEN
to a Team API Token or User API Token.INFRACOST_TERRAFORM_CLOUD_HOST
to your backend host, this overrides the defaultapp.terraform.io
value.
#
Terraform workspacesIf you use multiple Terraform workspaces, use an Infracost config file to define them; their results will be combined into the same breakdown or diff output.
If you'd like to select one workspace, you can do so by either:
- using the
--terraform-workspace
flag. - setting the
INFRACOST_TERRAFORM_WORKSPACE
environment variable (this sets theTF_WORKSPACE
internally).
Only set this for multi-workspace deployments, otherwise it might result in the Terraform error "workspaces not supported". If you see this error, try running unset INFRACOST_TERRAFORM_WORKSPACE
and unset TF_WORKSPACE
.