Output variables
After each run, the Terraform Plan, Apply, and Drift Detection actions export variables that later actions in the run can use - in trigger conditions, notifications, or commands.
A variable is exported only when it has a value. For example, DESTROY_RESOURCES isn't set when nothing is destroyed.
These are variables about the run, not Terraform output values. To pass an output such as a URL or an IP to later actions, read it with terraform output in the Terraform CLI action.
Plan and Apply
Plan exports BUDDY_ACTION_TF_PLAN_* and Apply exports BUDDY_ACTION_TF_APPLY_*, with the same suffixes:
| Suffix | Description |
|---|---|
OUTPUT_FILE | Path to the plan file, relative to the pipeline filesystem root. Plan only |
ADD_COUNT | Resources to create. Replacements aren't counted |
CHANGE_COUNT | Resources to update in place. Replacements aren't counted |
DESTROY_COUNT | Resources to destroy. Replacements aren't counted |
REPLACE_COUNT | Resources to replace, counted once |
TOTAL_COUNT | Resources with any change |
SUMMARY | X to add, Y to change, Z to destroy, as reported by the tool |
DESTROY_RESOURCES | Addresses of resources to destroy, one per line. Replacements aren't listed. Not set when nothing is destroyed |
WORKSPACE | Workspace the action ran in |
TOOL_VERSION | Terraform or OpenTofu version |
Image loading...
Counters versus summary
The counters and SUMMARY count replacements differently, on purpose:
- The counters count each resource once, in exactly one category. A replaced resource is only in
REPLACE_COUNT. SUMMARYfollows Terraform's convention, where a replacement is both an add and a destroy.
For a plan that creates one resource and replaces two:
| Variable | Value |
|---|---|
ADD_COUNT | 1 |
DESTROY_COUNT | 0 |
REPLACE_COUNT | 2 |
TOTAL_COUNT | 3 |
SUMMARY | 3 to add, 0 to change, 2 to destroy |
To check whether anything will be destroyed, including replacements, check DESTROY_COUNT or REPLACE_COUNT.
Drift Detection
| Variable | Description |
|---|---|
BUDDY_ACTION_TF_DRIFT_DETECTED | true when any resource differs from the state, false otherwise |
BUDDY_ACTION_TF_DRIFT_CHANGE_COUNT | Resources changed outside of Terraform |
BUDDY_ACTION_TF_DRIFT_DESTROY_COUNT | Resources removed outside of Terraform |
BUDDY_ACTION_TF_DRIFT_TOTAL_COUNT | Drifted resources |
BUDDY_ACTION_TF_DRIFT_SUMMARY | Summary of the drift |
BUDDY_ACTION_TF_DRIFT_RESOURCES | Addresses of all drifted resources, one per line |
BUDDY_ACTION_TF_DRIFT_DESTROY_RESOURCES | Addresses of removed resources, one per line |
BUDDY_ACTION_TF_DRIFT_OUTPUT_FILE | Path to the refresh-only plan file. Apply it to write the drift into the state |
BUDDY_ACTION_TF_DRIFT_WORKSPACE | Workspace the action ran in |
BUDDY_ACTION_TF_DRIFT_TOOL_VERSION | Terraform or OpenTofu version |
Cost estimation
With cost estimation enabled, Plan exports BUDDY_ACTION_TF_PLAN_COST_*, Drift Detection exports BUDDY_ACTION_TF_DRIFT_COST_*, and the Terraform Cost Estimation action exports BUDDY_ACTION_TF_COST_*. All three use the same suffixes:
| Suffix | Description |
|---|---|
MONTHLY | Monthly cost after the change, e.g. 17.58 |
PAST_MONTHLY | Monthly cost before the change |
DIFF_MONTHLY | Difference, negative when the cost goes down, e.g. -87.75 |
DIFF_PERCENT | Difference in percent, e.g. -83.3. Not set when the cost before the change is 0 |
CURRENCY | Currency, e.g. USD |
UNPRICED_COUNT | Number of resources without a price, e.g. outside AWS, Azure, and Google Cloud |
Amounts have two decimal places. In approval conditions, use DIFF_MONTHLY, because DIFF_PERCENT is not set for a new stack.
Image loading...
Examples
Show the plan to approvers:
- action: Approve
type: WAIT_FOR_APPLY
description: "$BUDDY_ACTION_TF_PLAN_SUMMARY in $BUDDY_ACTION_TF_PLAN_WORKSPACE"
Send a summary after apply:
- action: Notify
type: SLACK
integration: my-slack
channel: "#infra"
content: "Applied to $BUDDY_ACTION_TF_APPLY_WORKSPACE: $BUDDY_ACTION_TF_APPLY_SUMMARY ($BUDDY_RUN_URL)"
Show the cost of the change to the approver:
- action: Approve
type: WAIT_FOR_APPLY
description: "$BUDDY_ACTION_TF_PLAN_SUMMARY. Monthly cost: $BUDDY_ACTION_TF_PLAN_COST_PAST_MONTHLY -> $BUDDY_ACTION_TF_PLAN_COST_MONTHLY $BUDDY_ACTION_TF_PLAN_COST_CURRENCY ($BUDDY_ACTION_TF_PLAN_COST_DIFF_MONTHLY)"
More conditions are in Conditional apply and Drift detection.
REST API
The full diff, with every resource and its before and after values, is in the terraformPlan field of the action execution in the REST API.
Last modified on Nov 24, 2026