Terraform HCP Remote and CI Cheat Sheet/Select or create workspace

Common automation pattern for ephemeral or environment-specific workspaces.

Section: CI and Automation

Select or create workspace

bash
bash
terraform workspace select dev || terraform workspace new dev
Explanation

Common automation pattern for ephemeral or environment-specific workspaces.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing CI and Automation
Plan without color
Disable ANSI color codes for cleaner CI logs.
OpenIn sheetbashsame section
Apply for CI
Apply non-interactively in automation.
OpenIn sheetbashsame section
Init for CI
Avoid interactive backend/provider prompts in automation.
OpenIn sheetbashsame section
Save plan as pipeline artifact
Persist both binary and JSON plan outputs for later review or policy checks.
OpenIn sheetbash2 tag match
Custom TF_DATA_DIR in CI
Isolate Terraform local data in ephemeral build environments.
OpenIn sheetbash2 tag match
Basic validation step
Common fast feedback step before plan/apply.
OpenIn sheetbash2 tag match