YAML for Terraform Cost Estimation

View as Markdown

Estimate the monthly cost of a plan file produced by a preceding Terraform Plan action with Infracost, render it per resource and export it as BUDDY_ACTION_TF_COST_* variables.

YAML parameters for Terraform Cost Estimation

PARAMETERS
cost_estimationrequiredInfracostYaml
Infracost settings: integration (required) and usage_file. The action always estimates the cost and fails when Infracost fails.
toolrequiredstring enum
The Terraform tool to run: OPENTOFU, TERRAFORM (FOSS, up to 1.5.7) or CUSTOM.
Allowed enum:
OPENTOFU,
TERRAFORM,
CUSTOM
typerequiredstring

Value: TERRAFORM_COST_ESTIMATION

actionrequiredstring
Unique identifier for the action within the pipeline.
plan_file_pathstring
Path to the plan file. Defaults to $BUDDY_ACTION_TF_PLAN_OUTPUT_FILE (output of the preceding Terraform Plan action). The plan is read in the working directory of that Plan action, so set the same working_directory.
versionstring
Tool version, e.g. 1.9.0 or latest. Required unless tool is CUSTOM.
custom_binary_pathstring
Path to the binary inside the Docker image, e.g. /usr/local/bin/tofu. Required when tool is CUSTOM.
docker_image_namestring
Custom Docker image to run in. Required when tool is CUSTOM.
docker_image_tagstring
Tag of the custom Docker image.
image_locationstring enum
The location of the image used by the action.
Allowed enum:
PUBLIC_REGISTRY,
PRIVATE_REGISTRY,
ACTION,
ARTIFACT_REGISTRY
docker_registrystring enum
The type of registry from which the image is retrieved.
Allowed enum:
NONE,
DOCKER_HUB,
AMAZON_ECR,
GOOGLE_GCR,
GOOGLE_ARTIFACT_REGISTRY,
OTHER,
GIT_HUB_CONTAINER_REGISTRY,
ARTIFACT_REGISTRY,
DIGITAL_OCEAN_CONTAINER_REGISTRY
registrystring
The URL of the Docker registry. Required when docker_registry is OTHER.
loginstring
Username for Docker registry authentication. Used with password when docker_registry is OTHER.
passwordstring
Password for Docker registry authentication. Used with login when docker_registry is OTHER.
regionstring
The region of the Docker registry (for Amazon ECR).
integrationstring
Docker registry integration used to pull the custom image. It refers to an integration in the workspace by its identifier, not by its display name.
working_directorystring
Path relative to the repository root. Defaults to ..
trigger_timestring enum
Specifies when the action should be executed. ON_SUCCESS actions run after every successful run, also one ended by an EARLY_EXIT action.
Allowed enum:
ON_EVERY_EXECUTION,
ON_SUCCESS,
ON_FAILURE,
ON_BACK_TO_SUCCESS,
ON_WARNING,
ON_WAIT_FOR_APPROVE,
ON_TERMINATE
loopstring[]
Names of the variables to loop over (IMAGES, not $IMAGES and not a value). The action runs once for each item of the value, and once for each combination of items when several variables are listed. The variable value is split into items by new lines, or by commas when it has no new lines (a single-line JSON object or key=value pairs stays one item). An item that is a JSON object or key=value pairs also sets one variable per key, named <VARIABLE>_<key>; an item that starts with EXTRACT: sets them as plain <key>.
run_only_on_first_failureboolean
When true, the action runs only on the first failure instead of on each failure. Used only when trigger_time is ON_FAILURE.
disabledboolean
When set to true the action is disabled. By default it is set to false.
timeoutinteger
The timeout in seconds. It cannot exceed the action time limit of the workspace plan; a higher value is rejected.
ignore_errorsboolean
If set to true the execution will proceed, mark action as a warning and jump to the next action. Doesn't apply to deployment actions.
retry_intervalinteger
Delay time between auto retries in seconds.
retry_countinteger
Number of retries if the action fails.

Constraints: ≤ 10

run_nextstring enum
Defines whether the action should run in parallel with the next one.
Allowed enum:
WAIT_ON_SUCCESS,
IN_SOFT_PARALLEL,
IN_HARD_PARALLEL
trigger_conditionsTriggerConditionYaml[]
The list of trigger conditions to meet so that the action can be triggered.
variablesVariableYaml[]
The list of variables you can use in the action.

Outputs for Terraform Cost Estimation

OUTPUT VARIABLES
BUDDY_ACTION_TF_COST_MONTHLY
Estimated monthly cost after the change, as a decimal number without the currency.

Example: 515.20

BUDDY_ACTION_TF_COST_PAST_MONTHLY
Estimated monthly cost before the change, as a decimal number without the currency.

Example: 420.00

BUDDY_ACTION_TF_COST_DIFF_MONTHLY
Change of the estimated monthly cost, negative when the cost drops. Use it in a VAR_GREATER_THAN trigger condition to require an approval of a cost increase.

Example: 95.20

BUDDY_ACTION_TF_COST_DIFF_PERCENT
Change of the estimated monthly cost in percent of the cost before the change. Not exported when the cost before the change is 0.

Example: 22.7

BUDDY_ACTION_TF_COST_CURRENCY
Currency of the estimated costs.

Example: USD

BUDDY_ACTION_TF_COST_UNPRICED_COUNT
Number of resources Infracost does not support and left out of the estimation.

Example: 2

Last modified on Nov 26, 2026

YAML examples for Terraform Cost Estimation

Terraform Cost Estimation

yaml
- action: "Estimate cost"
  type: "TERRAFORM_COST_ESTIMATION"
  tool: "OPENTOFU"
  version: "1.9.0"
  cost_estimation:
    integration: "infracost"

Terraform Cost Estimation of an explicit plan file with a usage file

yaml
- action: "Estimate cost"
  type: "TERRAFORM_COST_ESTIMATION"
  tool: "OPENTOFU"
  version: "1.9.0"
  working_directory: "./infrastructure/prod"
  plan_file_path: "$BUDDY_ACTION_TF_PLAN_OUTPUT_FILE"
  cost_estimation:
    integration: "infracost"
    usage_file: "infracost-usage.yml"