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

AWS CodeCommit – Complete Step-by-Step Tutorial

Beginner to Advanced | macOS, Linux, Git, SSH, IAM, CodeBuild This master tutorial covers the complete AWS CodeCommit workflow, from creating your first repository to managing source…

Read More

AWS Developer Services: Console Lab Guide

title AWS Developer Services: Gold-Standard Console Lab Guide subtitle CodeCommit • CodeArtifact • CodeBuild • CodeDeploy • CodePipeline author Instructor Edition | Browser-Only Labs date 10 November…

Read More

Oracle Cloud Always Free VPS — Complete Step-by-Step Tutorial

Beginner to Advanced | Updated: November 2, 2026 | Verified against official Oracle Cloud Infrastructure documentation This guide walks you through logging in to Oracle Cloud, configuring…

Read More

Microsoft Sentinel Intermediate: One Complete End-to-End Hands-On Lab – Part – 3

Module 2: Intermediate | Day 3 only | Complete instructor-and-learner manual Edition: 1 November 2026Course: Microsoft Sentinel Technical Training — 5-day progressive curriculumThis document: Day 3 only; prerequisite: successful completion of Foundations…

Read More

Microsoft Sentinel Advance: One Complete End-to-End Hands-On Lab – Part – 4

Module 3: Advanced | Day 4 only | Detection Engineering, Threat Hunting and SOAR Curriculum version: 1 November 2026Course: Five-day progressive Microsoft Sentinel technical trainingThis manual: Day 4 only — syllabus competencies A01–A14Prerequisite: Demonstrated…

Read More

Microsoft Sentinel Advance: One Complete End-to-End Hands-On Lab – Part – 5

Module 3: Advanced | Day 5 only | Enterprise Architecture, Data Lake, DevSecOps and SOC Governance Edition: 1 November 2026Training path: Day 5 of the five-day progressive Microsoft Sentinel programThis manual: Day…

Read More