Workspaces Reference
Workspaces, backends and locking: the alias model, the configuration binding, where state lands, the lock, and the workspace tools (status, list, delete).
Alias model
Section titled “Alias model”Each open workspace has an alias that identifies it to this server:
- Default (alias omitted, or
"default"): every tool targets it when you pass noworkspace_alias, however many others are open. One default is open at a time. - Named (
"prod","staging"): open several at once, each under its own alias, and pass the alias to every later tool.
open({ config_alias: "app", workspace_name: "production" })→ { workspace_alias: "default", config_alias: "app", workspace_name: "production", backend_type: "local", state_path, lineage, serial, resource_count, resources, convergence?, warnings }open({ config_alias: "app", workspace_name: "staging", workspace_alias: "staging" })up({ workspace_alias: "staging" })The workspace name is a property of the backend — the OpenTofu workspace, a state slot, what terraform.workspace reads. The alias is this server’s handle. Opening a workspace already open under the same alias, the same way, returns it as it is. No lineage and no serial means no statefile yet: the first up writes one.
The configuration binding
Section titled “The configuration binding”A workspace opens against a configuration and stays bound to it for its whole life. config_alias names it (omitted: the one init registered without an alias). Everything else is read off it:
- The backend comes from the configuration’s
backend {}block.backend_config(andbackend_config_files) supply only what the block deliberately leaves out — credentials, per-environment values — merged per key over the declared ones, astofu init -backend-configdoes. A key the backend declares as a block is a nested object:{"workspaces": {"name": "…"}}forremote,{"assume_role": {"role_arn": "…"}}fors3.backend_typeis for a configuration that declares no backend; one contradicting a declared backend is refused — edit the block to move the store. - The providers are what the configuration requires:
opentakes none. To add or pin one, edit the files and re-runinit. - The configuration every plan projects: plan commands and readers name the workspace by
workspace_aliasalone.
Two workspaces may share one configuration — staging and production, differing in var values and workspace_name. Prefer var values as the axis: they reach the backend body, the provider blocks and the resources, while the workspace name reaches none of them. workspace_name is the interop knob: it addresses state a tofu workspace select user created.
The backend’s own credentials are read by this server, with this server’s environment — not the engine’s (references/credentials.md).
The remote backend (the Terraform Cloud/Enterprise/Scalr protocol) is supported for state storage and locking only: point it at a workspace whose execution mode is local. Its token comes from tofu login or TF_TOKEN_<host>.
Moving a backend — reconfigure
Section titled “Moving a backend — reconfigure”The engine records which backend each workspace’s state lives in. An open that reaches the same state through a different backend — the store moved, or a setting that identifies it changed — is refused at the next plan: “lineage … is bound to backend … and this open arrives from a different backend”. When the move is deliberate, open again with reconfigure: true (tofu init -reconfigure); the consent is taken at the next plan command. A statefile copied to a second backend is refused regardless: it must be given a new lineage.
Where a named workspace’s state lands
Section titled “Where a named workspace’s state lands”A backend’s path addresses the default workspace only. Every other name is routed through workspace_dir, which Turf anchors to the configuration directory (<config dir>/terraform.tfstate.d/<name>/terraform.tfstate). open returns state_path, already resolved, and warns when a declared path does not apply to this workspace.
The lock
Section titled “The lock”open reads the state without locking. The engine takes the state lock while a convergence runs, and holds it through every pause — at an approval point, at turf actions — as tofu apply holds it at its prompt. A detached convergence gives it back.
A stale lock (“the state is already locked by another tofu client”):
- Check for a convergence first.
openandstatusreport one holding the workspace, from this server or an earlier one: take it up withapplyor end it withcancel— never force-unlock it. - Otherwise ask the user. A lock may belong to an active operation in another tool, terminal or CI job, and force-unlocking an active lock can corrupt state.
- Only on their explicit yes:
open({ workspace_name: "…", force_unlock: true }). - Refused with “lock ID … does not match existing lock ID”: the backend names the lock by something else. Pass the ID the error names as
lock_id(impliesforce_unlock). Theremotebackend wants"<organization>/<workspace>". Some hosts (Scalr) do not implement force-unlock over the API: clear the lock in the host’s own UI.
Session scoping
Section titled “Session scoping”Workspace bindings belong to this server’s session; convergences do not. When the session ends, open workspaces close: a convergence this server was following is detached, never cancelled — it waits in the engine, and a later open reports it. Within a session a workspace stays open across turns until close, which ends the binding and never cancels or undoes anything.
status — what is open here
Section titled “status — what is open here”status({})→ { workspaces: [{ workspace_alias, config_alias, config_path, workspace_name, backend_type, state_path, lineage, opened_at, convergence: { id, kind, stage, round, open_questions, followed, next, drift }, drift: { counts, notices: [{ address, class, paths, source, first_seen }], omitted, coverage, next, note } }] }Check what is open before opening another, recall aliases, or see which convergence holds a workspace. A convergence’s drift is an up’s drift: { … } and where it stands, as its results carry it (references/drift.md).
Drift notices. Where the engine watches a workspace between convergences, drift lists its open drift notices: one entry per address, most severe first, with the class, the changed attribute paths (never values), the source and when it was first seen; omitted counts what the list left out, coverage how much is watched live, swept, or not read at all, and next is the plain up to call (then plan with refresh_drift: true). No block means detection is off, or was never turned on (or the engine has none); with nothing open, the block is the coverage line alone, or absent when the engine reports no coverage. What each class asks, watch and the scoped plan: references/drift.md.
list — what exists in the backend
Section titled “list — what exists in the backend”tofu workspace list, derived from the configuration as open derives it:
list({ config_alias: "app" })→ { workspaces: ["default", "staging", "production"] }"default" comes first; the rest are sorted. Refused when the backend body reads terraform.workspace: each workspace then keeps its state in a store of its own, and a list of one store would pass for the whole set.
delete
Section titled “delete”Permanently removes a workspace’s state from the backend — tofu workspace delete. Close it first. Only a workspace list shows can be deleted.
close({ workspace_alias: "staging" })delete({ config_alias: "app", workspace_name: "staging" })- The default workspace cannot be deleted; neither can an open one, or one a convergence holds (
cancelit first). - A workspace holding resources needs
force: true. That removes the state, never the cloud resources: they stop being tracked. Legitimate when the resources are already gone, when state has drifted past reconciling, or to forget everything at once. To delete the resources themselves,destroyfirst. - Check
resource_countin the result:0for a workspace you expected to hold resources means you addressed the wrong store.
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