Journey: Promotion across environments
One configuration, a stack per environment. Copying a configuration per environment is
how environments drift apart. Here staging and production are the same files: the
workspace name picks the state slot, env/<name>.tfvars carries what differs, and a change
is promoted by bumping one variable and planning each environment in turn — with a gate on
production that asks before it moves.
Example: terraform/language/environments in turf-examples. Credential-free
(hashicorp/random and the hashicorp/tfcoremock mock provider stand in for a service).
Load skill_deployment, and skill_authoring before beat 4 if it edits variables.tf. One
beat at a time; end each on a cue.
Beat 1 — The same files, twice (start here, tool-free)
Section titled “Beat 1 — The same files, twice (start here, tool-free)”Show main.tf — nothing in it knows which environment it is:
resource "random_pet" "name" { length = 2 }
resource "tfcoremock_simple_resource" "service" { string = "${var.environment}/${random_pet.name.id} v${var.app_version}" integer = var.replicas}and the two tfvars files (environment, replicas), and promote.turf.hcl — one file
for both environments, a trigger’s condition picking where each step fires:
action "turf_action" "smoke" { … } # after a change lands: read the service back, confirm version + replicas; taint on failureaction_trigger "smoke" { target = tfcoremock_simple_resource.service events = [after_create, after_update] actions = [action.turf_action.smoke] on_failure = taint }
action "turf_action" "gate" { … } # before production updates: has this version soaked in staging?action_trigger "gate" { target = tfcoremock_simple_resource.service events = [before_update] actions = [action.turf_action.gate] condition = var.environment == "production" on_failure = halt}Say the mechanism in one line: an OpenTofu workspace is a state slot the backend addresses
by name; open selects it with workspace_name, and every plan command carries
the environment’s values with var_file.
Your cue — “stand up staging.”
Beat 2 — Staging
Section titled “Beat 2 — Staging”init({ path: "<examples>/terraform/language/environments", config_alias: "env" }).open({ config_alias: "env", workspace_name: "staging", workspace_alias: "staging" })— point atstate_path:terraform.tfstate.d/staging/terraform.tfstate, beside the configuration.up({ workspace_alias: "staging", var_file: ["env/staging.tfvars"] })→ 2 to add;plan.invocationslistssmoke(after_create). Approve;apply→awaiting_actionsforsmoke: read the service back (state_list({ workspace_alias: "staging", include_values: true })), confirmv1.0.0and 1 replica, answer.converged.
Your cue — “now production.”
Beat 3 — Production, same files
Section titled “Beat 3 — Production, same files”open({ config_alias: "env", workspace_name: "production", workspace_alias: "production" }).up({ workspace_alias: "production", var_file: ["env/production.tfvars"] })→ the same two creates, production values (3 replicas). Approve;apply; answersmoke.list({ config_alias: "env" })→ both slots.
Two stacks, one configuration, nothing copied.
Your cue — “promote a change.”
Beat 4 — Promote a change
Section titled “Beat 4 — Promote a change”Edit main.tf? No — the version is a variable with a default; edit variables.tf’s
app_version default to 1.1.0 (say which file), or pass var: { app_version: "1.1.0" }
on each plan. Then:
- Staging first.
up({ workspace_alias: "staging", var_file: ["env/staging.tfvars"] })→ 1 to change (the string),smokeonafter_update(the engine lists it withon_failure: halt— taint applies to a create; on an update a failure halts); no gate — the condition is false in staging. Approve;apply; answersmoke. - Then production.
up({ workspace_alias: "production", var_file: ["env/production.tfvars"] })→ 1 to change, and now two invocations:gate(before_update, halt) thensmoke. Approve;apply→awaiting_actionsforgate: ask the user whetherv1.1.0has soaked in staging long enough. Quote them. A “yes” lets the update land andsmokefollows; a “no” issucceeded: falsewith their reason, and production stays onv1.0.0.
Make the point: one overlay, two environments, the condition decides where the question is asked — and the answer is in the record.
Your cue — “wrap it up.”
Beat 5 — Close
Section titled “Beat 5 — Close”Offer teardown (destroy({ workspace_alias: "staging" }), plan({ workspace_alias: "staging", refresh: false }), and the same for
production — approve each, apply), then close both aliases. Nothing real was
created. For the workspace model in depth — persistence, reopening from nothing but the
directory, remote backends — read skill_deployment → references/workspaces.md.
Turf™ is a trademark of Turf LLC. Terraform® is a trademark of HashiCorp. Ansible® is a trademark of Red Hat, LLC, registered in the United States and other countries. Helm®, Kubernetes®, Prometheus® and OpenTelemetry® are registered trademarks, and Jaeger™ is a trademark, of the Linux Foundation. OpenTofu® and Model Context Protocol® are registered trademarks of LF Projects, LLC. All other trademarks are the property of their respective owners. Turf is not affiliated with, endorsed by, or sponsored by HashiCorp, IBM, Red Hat, the Linux Foundation, LF Projects or the OpenTofu project.
© 2026 Turf LLC. Free for individuals, education and small businesses within the Community limits, under the Turf Community Edition License 1.0. Government and larger organizations need a commerciallicense.turf.build · Discord ·GitHub