World map

 

BM: Baca dalam Bahasa Melayu

World T3: State & Teams

Workspaces or folders per environment?

You will learn: when a second register (a workspace) is enough, and when each environment needs its own folder.

Checked with OpenTofu 1.13 on 1 Nov 2026

The problem

Kedai Kancil wants a test copy of the shop, next to the real one. Same blueprint. How many registers do you need?

Pick one answer.

Watch

bash
tofu workspace list
* default
tofu workspace new test
Created and switched to workspace "test"!
You're now on a new, empty workspace. Workspaces isolate their state,
so if you run "tofu plan" OpenTofu will not see any existing state
for this configuration.
tofu workspace list
default
* test
Real OpenTofu: workspace list shows only default. workspace new test creates and switches to test. workspace list then shows default and test, with a star on test.

A workspace: A second register for the same blueprint and backend. Good for short test copies. is a second register for the same blueprint, in the same backend. The star shows the one you are in.

Try it

This blueprint puts terraform.workspace in the file name. Run tofu apply. Which sign appears?

Blueprint (your .tf files)init done

  • local_file.signnot built yet

Built (the state file)

Nothing built yet.

Blueprint: 1 resources. Built: 0.

Change a file, then run tofu plan to see what it means.

Predict

Now someone switches to the workspace test and applies. What is the new file called?

Pick one answer.

Check

Workspace or separate folder? Sort each need.

Drag a card into a box. Or tap the card, then tap the box.

      Watch

      Tap the folder that both environments share.

      0 of 1 found

      Folders per environment: each one has its own backend, keys and reviewers. A module keeps them alike. That is World T4.

      Try it

      Build the command that switches to test, and makes it if it is missing.

      Tap the pieces in the right order.

      …

      You did it!

      You can now choose between a workspace and a folder per environment.

      Go deeper (optional)

      With the local backend, workspace registers live in terraform.tfstate.d/<name>/. The practice terminal has one workspace only, so try the rest at home. Where the story breaks: a real building can’t be copied in a second. A register can, so guard it.

      Real mission

      1. tofu init && tofu workspace new test
      2. tofu apply
      3. tofu workspace select default && tofu state list
      4. tofu workspace select test && tofu destroy && tofu workspace select default && tofu workspace delete test

      0 of 4 steps done Β· Your ticks are saved.