Listing the Default Workspace
Run:*) indicates the currently active workspace.
Creating and Switching Workspaces
Create and switch to new workspaces:Each workspace has its own isolated state. New workspaces start empty until you run
tofu apply.Workspace Commands Reference
Using Workspaces in Configuration
Suppose your project directory at/root/opentofu/projects/webserver defines an AWS EC2 instance. You need:
- Development:
t2.micro - Production:
m5.large - Region:
ca-central-1 - AMI: same for both environments

variables.tf to define instance_type as a map:
main.tf, use lookup with terraform.workspace and add dynamic tags:
Verifying Workspace Values
Open the OpenTofu console to inspect workspace-specific values:Applying Changes per Workspace
In the development workspace:Local State File Organization
When using local state, OpenTofu organizes workspace-specific state underterraform.tfstate.d:
terraform.tfstate file for its workspace.
That’s it for this lesson. See you in the next one!