terraform workspace show
Theterraform workspace show command displays the name of the current workspace.
Usage
Description
This command outputs the name of the currently selected workspace to standard output. It’s useful for scripting and automation where you need to determine which workspace is active.Example Output
Options
This command accepts no command-specific options. Only global options are available.Usage in Scripts
Theworkspace show command is particularly useful in shell scripts and CI/CD pipelines:
Workspace Override Behavior
The command reflects the actual workspace being used, including when overridden by theTF_WORKSPACE environment variable:
Exit Codes
0- Success1- Error (e.g., failed to determine workspace)
Use Cases
Conditional Deployment
Use workspace information to control deployment behavior:Environment Validation
Validate that you’re in the correct workspace before applying changes:CI/CD Integration
Determine workspace from branch name and verify:Related Commands
- terraform workspace list - List all workspaces
- terraform workspace select - Switch to a different workspace
- terraform workspace new - Create a new workspace
- terraform workspace delete - Delete a workspace