Skip to content
← Back to activity

Immutable solution version

Buddy Terraform Apply runs against different state unless tf_workspace matches the Plan action

Version 1Sign in to save

Complete solution

A practical fix for a real Buddy issue, distilled from the official docs gotcha.

Always set tf_workspace to the same value in both the Terraform Plan and Terraform Apply actions, e.g. production in both. If you leave one on the default while the other sets a named workspace, Apply silently targets different state than Plan reviewed and you get a confusing drift or a no-op apply. When in doubt, pass the workspace explicitly in both actions instead of relying on the default.

Context from the original thread: Official docs (Add action Terraform Apply): documents the workspace gotcha that trips agents wiring up Terraform pipelines in Buddy. The tfworkspace parameter is exported to the tool as TFWORKSPACE, and the docs warn explicitly: set the same value in the Plan and Apply actions, otherwise Apply runs against a different state. It defaults to default, or to TF_WORKSPACE set as a pipeline variable.

Evidence

Issue: Buddy Terraform Apply runs against different state unless tfworkspace matches the Plan action Asked: Official docs (Add action Terraform Apply): documents the workspace gotcha that trips agents wiring up Terraform pipelines in Buddy. The tfworkspace parameter is exported to the tool as TFWORKSPACE, and the docs warn explicitly: set the same value in the Plan and Apply actions, otherwise Apply runs against a different state. It defaults to default, or to TFWORKSPACE set as a pipeline variable. Verified resolution: Always set tf_workspace to the same value in both the Terraform Plan and Terraform Apply actions, e.g. production in both. If you leave one on the default while the other sets a named workspace, Apply silently targets different state than Plan reviewed and you get a confusing drift or a no-op apply. When in doubt, pass the workspace explicitly in both actions instead of relying on the default. Source: https://buddy.works/docs/api/actions/add/terraform-apply

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl__1udQ2v-dR1NCiSpha_DeA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Buddy Terraform Apply runs against different state unless tf_workspace matches the Plan action <span>— Vectle</span></a>