HCP Terraform Cloud CLI — Master Command Summary Table

Organization: motoshare | Project: proezi | Workspaces: proezi_dev, proezi_stage, proezi_prod

1. Terraform CLI — Complete Command Reference

CategoryCommandPurpose / Usage
Installationterraform versionCheck installed Terraform version
Helpterraform -helpList available commands
Helpterraform plan -helpView usage and options for a specific command
Authenticationterraform loginAuthenticate with HCP Terraform
Authenticationterraform logoutRemove locally saved HCP credentials
Initializationterraform initInitialize configuration, providers, modules, and HCP workspace connection
Initializationterraform init -upgradeUpgrade providers and modules within configured version constraints
Initializationterraform init -reconfigureReinitialize cloud/backend configuration
Initializationterraform init -migrate-stateMigrate Terraform state to another backend
Formattingterraform fmtFormat Terraform configuration
Formattingterraform fmt -recursiveFormat Terraform files recursively
Formattingterraform fmt -checkCheck formatting without modifying files
Validationterraform validateValidate configuration syntax and structure
Planningterraform planPreview infrastructure changes
Planningterraform plan -var="replicas=3"Override an input variable for a run
Planningterraform plan -var-file=dev.tfvarsUse a specific variable file
Planningterraform plan -out=tfplanSave a plan for later review and apply
Planningterraform plan -detailed-exitcodeReturn 0 = no changes, 1 = error, 2 = changes
Planningterraform plan -refresh-onlyPreview updates to state based on actual infrastructure
Planningterraform plan -replace=aws_instance.webPlan replacement of a specific resource
Planningterraform plan -target=aws_instance.webPlan changes for a targeted resource and dependencies
Applyterraform applyExecute Terraform changes
Applyterraform apply -auto-approveApply without interactive confirmation
Applyterraform apply tfplanApply a previously saved plan
Applyterraform apply -refresh-onlyUpdate state to reflect actual infrastructure
Destroyterraform plan -destroyPreview resource destruction
Destroyterraform destroyDestroy managed infrastructure in the selected state
Destroyterraform destroy -target=aws_instance.webTarget a resource for destruction
Stateterraform state listList resources in Terraform state
Stateterraform state show aws_instance.webShow details of one tracked resource
Stateterraform state pullRetrieve state from HCP Terraform
Stateterraform state mv OLD NEWMove or rename a resource address in state
Stateterraform state rm ADDRESSRemove resource tracking without destroying the object
Stateterraform state replace-provider OLD NEWReplace provider references within state
Importterraform import ADDRESS IDImport existing infrastructure into Terraform state
Lockingterraform force-unlock LOCK_IDRelease a stuck state lock where supported
Workspaceterraform workspace listList available workspaces
Workspaceterraform workspace showDisplay currently selected workspace
Workspaceterraform workspace select proezi_devSelect an existing workspace where supported
Workspaceterraform workspace new demoCreate a new workspace where supported
Workspaceterraform workspace delete demoDelete an eligible workspace
Outputsterraform outputDisplay Terraform outputs
Outputsterraform output -jsonDisplay outputs in JSON format
Outputsterraform output -raw app_nameRetrieve an output as a raw string
Inspectionterraform showDisplay current state information
Inspectionterraform show tfplanDisplay a saved execution plan
Inspectionterraform show -json tfplanDisplay a saved plan as JSON
Providersterraform providersList provider dependencies
Modulesterraform getDownload modules; terraform init is generally preferred
Consoleterraform consoleTest Terraform expressions interactively
Graphterraform graphGenerate an infrastructure dependency graph
Testingterraform testRun Terraform configuration tests
Directoryterraform -chdir=dev planExecute a command inside a selected directory

2. Terraform Cloud Environment Variables

Variable / CommandPurpose
export TF_TOKEN_app_terraform_io="$TFC_TOKEN"Authenticate to HCP Terraform using an API token
export TF_WORKSPACE=proezi_devSelect an existing workspace when the cloud configuration supports selection
export TF_VAR_replicas=3Supply a Terraform input variable
export TF_LOG=DEBUGEnable detailed Terraform CLI logging
export TF_LOG_PATH=terraform.logSave diagnostic logs to a file
export TF_IN_AUTOMATION=trueAdjust CLI output for automation
terraform plan -input=falseDisable interactive input
terraform apply -input=falseDisable interactive input during apply
unset TF_VAR_replicasRemove the shell variable override

3. HCP Terraform REST API — Command Summary

These are API operations executed using curl, not built-in terraform subcommands.

Base URL:

https://app.terraform.io/api/v2
OperationMethodAPI endpoint
List organization workspacesGET/organizations/motoshare/workspaces
Get Dev workspace detailsGET/organizations/motoshare/workspaces/proezi_dev
Get Stage workspace detailsGET/organizations/motoshare/workspaces/proezi_stage
Get Prod workspace detailsGET/organizations/motoshare/workspaces/proezi_prod
Create workspacePOST/organizations/motoshare/workspaces
Update workspacePATCH/workspaces/:workspace_id
List workspace variablesGET/workspaces/:workspace_id/vars
Create workspace variablePOST/workspaces/:workspace_id/vars
Update workspace variablePATCH/workspaces/:workspace_id/vars/:variable_id
Delete workspace variableDELETE/workspaces/:workspace_id/vars/:variable_id
List workspace runsGET/workspaces/:workspace_id/runs
Create a runPOST/runs
Get run detailsGET/runs/:run_id
Apply a runPOST/runs/:run_id/actions/apply
Lock workspacePOST/workspaces/:workspace_id/actions/lock
Unlock workspacePOST/workspaces/:workspace_id/actions/unlock
Safely delete empty workspacePOST/workspaces/:workspace_id/actions/safe-delete

Example — List all workspaces in motoshare:

curl -fsS \
  -H "Authorization: Bearer $TFC_TOKEN" \
  "https://app.terraform.io/api/v2/organizations/motoshare/workspaces" \
  | jq -r '.data[].attributes.name'

4. Most Important Commands for Daily DevOps Work

StepCommandWhen to use
1terraform loginFirst-time HCP authentication
2terraform initInitialize a working directory
3terraform fmt -checkCheck code formatting
4terraform validateValidate configuration
5terraform planReview proposed changes
6terraform plan -out=tfplanSave an executable plan
7terraform show tfplanReview the saved plan
8terraform apply tfplanApply the approved plan
9terraform outputView infrastructure outputs
10terraform state listInspect tracked resources
11terraform workspace showConfirm the selected workspace
12terraform plan -refresh-onlyCheck for external infrastructure changes

Critical HCP Terraform rules: With a fixed cloud.workspaces.name, you cannot switch between Dev, Stage, and Prod using terraform workspace select. Remote VCS-driven workspaces also do not support applying local configurations directly with terraform apply. Saved remote plans require a supported CLI version (Terraform 1.6+) and must be applied in their originating workspace.

For your motoshare organization, I recommend keeping CLI experimentation in a dedicated lab workspace and using reviewed plans and protected approval workflows for proezi_prod.

Related Posts

Terraform tflint terraform-docs trivy tenv pre-commit Tools — Installation Guide for Windows PowerShell

Updated: October 2026 | Windows 10/11 | PowerShell 5.1 / 7 This guide covers installing, verifying, and running the first commands for five Terraform development tools. Tool…

Read More

HCP Terraform Cloud CLI — Complete Master Tutorial

HCP Terraform Cloud — CLI Command Summary Organization: motoshare | Project: proezi # Cloud operation Command / Example Usage 1 Login to Terraform Cloud terraform login Authenticate…

Read More

Terraform Lab – Azure Hands-On – Terraform Functions

Beginner to Intermediate · 8 modules · 22 progressively designed labs · 20 local-only labs + 2 optional cloud labs · Updated 14 October 2026 Purpose: learn Terraform…

Read More

Terraform Lab – Azure Hands-On – Terraform Template

Level: Beginner to IntermediateFormat: Tutorial + concept guide + practical lab workbookModules: 6 | Labs: 12 | Cloud emphasis: Azure Linux VM, AWS EC2 comparisonBaseline: Terraform 1.15.9+ (within 1.x); AzureRM 5.9.x; AWS provider 6.xUpdated: 14 October…

Read More

Terraform Lab – Azure Hands-On – Terraform Modules

Course level: Beginner → IntermediateCourse type: Tutorial + runnable hands-on exercises + instructor checkpointsUpdated: 14 October 2026Terraform: >= 1.15.0, < 2.0.0 (lab baseline: 1.15.9)AzureRM provider: ~> 5.9.0 (root; child modules declare >= 5.9.0)Azure baseline: eastus, Ubuntu…

Read More

Terraform Lab – Azure Hands-On – Conditional Expressions and Logic

This workbook teaches the complete set of Terraform conditionals, filtering, validation, null handling, and related functions from the requested syllabus. Every numbered concept includes one standalone AWS EC2…

Read More