Explore how Terraform workspaces can separate environments like dev and prod.
Understand the basics of listing and switching workspaces.
Inspect the workspaces available in the current project.
Command
terraform workspace listExpected Result
You should see the default workspace and any others already created.
Create a separate environment context for testing.
Command
terraform workspace new devExpected Result
Terraform should create and switch to the new dev workspace.
Verify that the new workspace now exists.
Command
terraform workspace listExpected Result
You should see both default and dev workspaces.
Return to the default environment context.
Command
terraform workspace select defaultExpected Result
Terraform should switch back to the default workspace.
List workspaces once more to verify which one is active.
Command
terraform workspace listExpected Result
You should see the active workspace marked in the output.
You can list, create, and switch Terraform workspaces.
You understand the idea of separating environment context in a simple way.