{"id":1251,"date":"2026-10-15T10:18:54","date_gmt":"2026-10-15T10:18:54","guid":{"rendered":"https:\/\/www.devopsschool.com\/tutorials\/?p=1251"},"modified":"2026-10-15T10:18:55","modified_gmt":"2026-10-15T10:18:55","slug":"hcp-terraform-cloud-cli-master-command-summary-table","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/tutorials\/hcp-terraform-cloud-cli-master-command-summary-table\/","title":{"rendered":"HCP Terraform Cloud CLI \u2014 Master Command Summary Table"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Organization: <code>motoshare<\/code> | Project: <code>proezi<\/code> | Workspaces: <code>proezi_dev<\/code>, <code>proezi_stage<\/code>, <code>proezi_prod<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Terraform CLI \u2014 Complete Command Reference<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Category<\/th><th>Command<\/th><th>Purpose \/ Usage<\/th><\/tr><tr><td>Installation<\/td><td><code>terraform version<\/code><\/td><td>Check installed Terraform version<\/td><\/tr><tr><td>Help<\/td><td><code>terraform -help<\/code><\/td><td>List available commands<\/td><\/tr><tr><td>Help<\/td><td><code>terraform plan -help<\/code><\/td><td>View usage and options for a specific command<\/td><\/tr><tr><td>Authentication<\/td><td><code>terraform login<\/code><\/td><td>Authenticate with HCP Terraform<\/td><\/tr><tr><td>Authentication<\/td><td><code>terraform logout<\/code><\/td><td>Remove locally saved HCP credentials<\/td><\/tr><tr><td>Initialization<\/td><td><code>terraform init<\/code><\/td><td>Initialize configuration, providers, modules, and HCP workspace connection<\/td><\/tr><tr><td>Initialization<\/td><td><code>terraform init -upgrade<\/code><\/td><td>Upgrade providers and modules within configured version constraints<\/td><\/tr><tr><td>Initialization<\/td><td><code>terraform init -reconfigure<\/code><\/td><td>Reinitialize cloud\/backend configuration<\/td><\/tr><tr><td>Initialization<\/td><td><code>terraform init -migrate-state<\/code><\/td><td>Migrate Terraform state to another backend<\/td><\/tr><tr><td>Formatting<\/td><td><code>terraform fmt<\/code><\/td><td>Format Terraform configuration<\/td><\/tr><tr><td>Formatting<\/td><td><code>terraform fmt -recursive<\/code><\/td><td>Format Terraform files recursively<\/td><\/tr><tr><td>Formatting<\/td><td><code>terraform fmt -check<\/code><\/td><td>Check formatting without modifying files<\/td><\/tr><tr><td>Validation<\/td><td><code>terraform validate<\/code><\/td><td>Validate configuration syntax and structure<\/td><\/tr><tr><td>Planning<\/td><td><code>terraform plan<\/code><\/td><td>Preview infrastructure changes<\/td><\/tr><tr><td>Planning<\/td><td><code>terraform plan -var=\"replicas=3\"<\/code><\/td><td>Override an input variable for a run<\/td><\/tr><tr><td>Planning<\/td><td><code>terraform plan -var-file=dev.tfvars<\/code><\/td><td>Use a specific variable file<\/td><\/tr><tr><td>Planning<\/td><td><code>terraform plan -out=tfplan<\/code><\/td><td>Save a plan for later review and apply<\/td><\/tr><tr><td>Planning<\/td><td><code>terraform plan -detailed-exitcode<\/code><\/td><td>Return 0 = no changes, 1 = error, 2 = changes<\/td><\/tr><tr><td>Planning<\/td><td><code>terraform plan -refresh-only<\/code><\/td><td>Preview updates to state based on actual infrastructure<\/td><\/tr><tr><td>Planning<\/td><td><code>terraform plan -replace=aws_instance.web<\/code><\/td><td>Plan replacement of a specific resource<\/td><\/tr><tr><td>Planning<\/td><td><code>terraform plan -target=aws_instance.web<\/code><\/td><td>Plan changes for a targeted resource and dependencies<\/td><\/tr><tr><td>Apply<\/td><td><code>terraform apply<\/code><\/td><td>Execute Terraform changes<\/td><\/tr><tr><td>Apply<\/td><td><code>terraform apply -auto-approve<\/code><\/td><td>Apply without interactive confirmation<\/td><\/tr><tr><td>Apply<\/td><td><code>terraform apply tfplan<\/code><\/td><td>Apply a previously saved plan<\/td><\/tr><tr><td>Apply<\/td><td><code>terraform apply -refresh-only<\/code><\/td><td>Update state to reflect actual infrastructure<\/td><\/tr><tr><td>Destroy<\/td><td><code>terraform plan -destroy<\/code><\/td><td>Preview resource destruction<\/td><\/tr><tr><td>Destroy<\/td><td><code>terraform destroy<\/code><\/td><td>Destroy managed infrastructure in the selected state<\/td><\/tr><tr><td>Destroy<\/td><td><code>terraform destroy -target=aws_instance.web<\/code><\/td><td>Target a resource for destruction<\/td><\/tr><tr><td>State<\/td><td><code>terraform state list<\/code><\/td><td>List resources in Terraform state<\/td><\/tr><tr><td>State<\/td><td><code>terraform state show aws_instance.web<\/code><\/td><td>Show details of one tracked resource<\/td><\/tr><tr><td>State<\/td><td><code>terraform state pull<\/code><\/td><td>Retrieve state from HCP Terraform<\/td><\/tr><tr><td>State<\/td><td><code>terraform state mv OLD NEW<\/code><\/td><td>Move or rename a resource address in state<\/td><\/tr><tr><td>State<\/td><td><code>terraform state rm ADDRESS<\/code><\/td><td>Remove resource tracking without destroying the object<\/td><\/tr><tr><td>State<\/td><td><code>terraform state replace-provider OLD NEW<\/code><\/td><td>Replace provider references within state<\/td><\/tr><tr><td>Import<\/td><td><code>terraform import ADDRESS ID<\/code><\/td><td>Import existing infrastructure into Terraform state<\/td><\/tr><tr><td>Locking<\/td><td><code>terraform force-unlock LOCK_ID<\/code><\/td><td>Release a stuck state lock where supported<\/td><\/tr><tr><td>Workspace<\/td><td><code>terraform workspace list<\/code><\/td><td>List available workspaces<\/td><\/tr><tr><td>Workspace<\/td><td><code>terraform workspace show<\/code><\/td><td>Display currently selected workspace<\/td><\/tr><tr><td>Workspace<\/td><td><code>terraform workspace select proezi_dev<\/code><\/td><td>Select an existing workspace where supported<\/td><\/tr><tr><td>Workspace<\/td><td><code>terraform workspace new demo<\/code><\/td><td>Create a new workspace where supported<\/td><\/tr><tr><td>Workspace<\/td><td><code>terraform workspace delete demo<\/code><\/td><td>Delete an eligible workspace<\/td><\/tr><tr><td>Outputs<\/td><td><code>terraform output<\/code><\/td><td>Display Terraform outputs<\/td><\/tr><tr><td>Outputs<\/td><td><code>terraform output -json<\/code><\/td><td>Display outputs in JSON format<\/td><\/tr><tr><td>Outputs<\/td><td><code>terraform output -raw app_name<\/code><\/td><td>Retrieve an output as a raw string<\/td><\/tr><tr><td>Inspection<\/td><td><code>terraform show<\/code><\/td><td>Display current state information<\/td><\/tr><tr><td>Inspection<\/td><td><code>terraform show tfplan<\/code><\/td><td>Display a saved execution plan<\/td><\/tr><tr><td>Inspection<\/td><td><code>terraform show -json tfplan<\/code><\/td><td>Display a saved plan as JSON<\/td><\/tr><tr><td>Providers<\/td><td><code>terraform providers<\/code><\/td><td>List provider dependencies<\/td><\/tr><tr><td>Modules<\/td><td><code>terraform get<\/code><\/td><td>Download modules; <code>terraform init<\/code> is generally preferred<\/td><\/tr><tr><td>Console<\/td><td><code>terraform console<\/code><\/td><td>Test Terraform expressions interactively<\/td><\/tr><tr><td>Graph<\/td><td><code>terraform graph<\/code><\/td><td>Generate an infrastructure dependency graph<\/td><\/tr><tr><td>Testing<\/td><td><code>terraform test<\/code><\/td><td>Run Terraform configuration tests<\/td><\/tr><tr><td>Directory<\/td><td><code>terraform -chdir=dev plan<\/code><\/td><td>Execute a command inside a selected directory<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">2. Terraform Cloud Environment Variables<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Variable \/ Command<\/th><th>Purpose<\/th><\/tr><tr><td><code>export TF_TOKEN_app_terraform_io=\"$TFC_TOKEN\"<\/code><\/td><td>Authenticate to HCP Terraform using an API token<\/td><\/tr><tr><td><code>export TF_WORKSPACE=proezi_dev<\/code><\/td><td>Select an existing workspace when the cloud configuration supports selection<\/td><\/tr><tr><td><code>export TF_VAR_replicas=3<\/code><\/td><td>Supply a Terraform input variable<\/td><\/tr><tr><td><code>export TF_LOG=DEBUG<\/code><\/td><td>Enable detailed Terraform CLI logging<\/td><\/tr><tr><td><code>export TF_LOG_PATH=terraform.log<\/code><\/td><td>Save diagnostic logs to a file<\/td><\/tr><tr><td><code>export TF_IN_AUTOMATION=true<\/code><\/td><td>Adjust CLI output for automation<\/td><\/tr><tr><td><code>terraform plan -input=false<\/code><\/td><td>Disable interactive input<\/td><\/tr><tr><td><code>terraform apply -input=false<\/code><\/td><td>Disable interactive input during apply<\/td><\/tr><tr><td><code>unset TF_VAR_replicas<\/code><\/td><td>Remove the shell variable override<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">3. HCP Terraform REST API \u2014 Command Summary<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These are API operations executed using <code>curl<\/code>, not built-in <code>terraform<\/code> subcommands.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Base URL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;app.terraform.io\/api\/v2<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Operation<\/th><th>Method<\/th><th>API endpoint<\/th><\/tr><tr><td>List organization workspaces<\/td><td>GET<\/td><td><code>\/organizations\/motoshare\/workspaces<\/code><\/td><\/tr><tr><td>Get Dev workspace details<\/td><td>GET<\/td><td><code>\/organizations\/motoshare\/workspaces\/proezi_dev<\/code><\/td><\/tr><tr><td>Get Stage workspace details<\/td><td>GET<\/td><td><code>\/organizations\/motoshare\/workspaces\/proezi_stage<\/code><\/td><\/tr><tr><td>Get Prod workspace details<\/td><td>GET<\/td><td><code>\/organizations\/motoshare\/workspaces\/proezi_prod<\/code><\/td><\/tr><tr><td>Create workspace<\/td><td>POST<\/td><td><code>\/organizations\/motoshare\/workspaces<\/code><\/td><\/tr><tr><td>Update workspace<\/td><td>PATCH<\/td><td><code>\/workspaces\/:workspace_id<\/code><\/td><\/tr><tr><td>List workspace variables<\/td><td>GET<\/td><td><code>\/workspaces\/:workspace_id\/vars<\/code><\/td><\/tr><tr><td>Create workspace variable<\/td><td>POST<\/td><td><code>\/workspaces\/:workspace_id\/vars<\/code><\/td><\/tr><tr><td>Update workspace variable<\/td><td>PATCH<\/td><td><code>\/workspaces\/:workspace_id\/vars\/:variable_id<\/code><\/td><\/tr><tr><td>Delete workspace variable<\/td><td>DELETE<\/td><td><code>\/workspaces\/:workspace_id\/vars\/:variable_id<\/code><\/td><\/tr><tr><td>List workspace runs<\/td><td>GET<\/td><td><code>\/workspaces\/:workspace_id\/runs<\/code><\/td><\/tr><tr><td>Create a run<\/td><td>POST<\/td><td><code>\/runs<\/code><\/td><\/tr><tr><td>Get run details<\/td><td>GET<\/td><td><code>\/runs\/:run_id<\/code><\/td><\/tr><tr><td>Apply a run<\/td><td>POST<\/td><td><code>\/runs\/:run_id\/actions\/apply<\/code><\/td><\/tr><tr><td>Lock workspace<\/td><td>POST<\/td><td><code>\/workspaces\/:workspace_id\/actions\/lock<\/code><\/td><\/tr><tr><td>Unlock workspace<\/td><td>POST<\/td><td><code>\/workspaces\/:workspace_id\/actions\/unlock<\/code><\/td><\/tr><tr><td>Safely delete empty workspace<\/td><td>POST<\/td><td><code>\/workspaces\/:workspace_id\/actions\/safe-delete<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Example \u2014 List all workspaces in <code>motoshare<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -fsS \\\n  -H \"Authorization: Bearer $TFC_TOKEN\" \\\n  \"https:\/\/app.terraform.io\/api\/v2\/organizations\/motoshare\/workspaces\" \\\n  | jq -r '.data&#91;].attributes.name'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4. Most Important Commands for Daily DevOps Work<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Step<\/th><th>Command<\/th><th>When to use<\/th><\/tr><tr><td>1<\/td><td><code>terraform login<\/code><\/td><td>First-time HCP authentication<\/td><\/tr><tr><td>2<\/td><td><code>terraform init<\/code><\/td><td>Initialize a working directory<\/td><\/tr><tr><td>3<\/td><td><code>terraform fmt -check<\/code><\/td><td>Check code formatting<\/td><\/tr><tr><td>4<\/td><td><code>terraform validate<\/code><\/td><td>Validate configuration<\/td><\/tr><tr><td>5<\/td><td><code>terraform plan<\/code><\/td><td>Review proposed changes<\/td><\/tr><tr><td>6<\/td><td><code>terraform plan -out=tfplan<\/code><\/td><td>Save an executable plan<\/td><\/tr><tr><td>7<\/td><td><code>terraform show tfplan<\/code><\/td><td>Review the saved plan<\/td><\/tr><tr><td>8<\/td><td><code>terraform apply tfplan<\/code><\/td><td>Apply the approved plan<\/td><\/tr><tr><td>9<\/td><td><code>terraform output<\/code><\/td><td>View infrastructure outputs<\/td><\/tr><tr><td>10<\/td><td><code>terraform state list<\/code><\/td><td>Inspect tracked resources<\/td><\/tr><tr><td>11<\/td><td><code>terraform workspace show<\/code><\/td><td>Confirm the selected workspace<\/td><\/tr><tr><td>12<\/td><td><code>terraform plan -refresh-only<\/code><\/td><td>Check for external infrastructure changes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Critical HCP Terraform rules: With a fixed <code>cloud.workspaces.name<\/code>, you cannot switch between Dev, Stage, and Prod using <code>terraform workspace select<\/code>. Remote VCS-driven workspaces also do not support applying local configurations directly with <code>terraform apply<\/code>. Saved remote plans require a supported CLI version (Terraform 1.6+) and must be applied in their originating workspace.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For your <code>motoshare<\/code> organization, I recommend keeping CLI experimentation in a dedicated lab workspace and using reviewed plans and protected approval workflows for <code>proezi_prod<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Organization: motoshare | Project: proezi | Workspaces: proezi_dev, proezi_stage, proezi_prod 1. Terraform CLI \u2014 Complete Command Reference Category Command Purpose \/ Usage Installation terraform version Check installed&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1251","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/posts\/1251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/comments?post=1251"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/posts\/1251\/revisions"}],"predecessor-version":[{"id":1252,"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/posts\/1251\/revisions\/1252"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/media?parent=1251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/categories?post=1251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/tutorials\/wp-json\/wp\/v2\/tags?post=1251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}