All Shortcuts

Terraform Shortcuts & Commands — Complete Cheat Sheet (26)

Complete Terraform CLI commands cheat sheet for infrastructure as code. Covers init, plan, apply, state management, workspaces, and import operations.

Terraform's CLI is a workflow: init, plan, apply, and a few commands around the state file that records what exists. The ten commands here are the ones a practitioner runs; the notes cover the order and the two mistakes that cost the most — applying without reading the plan, and editing state by hand.

Related Shortcut Pages

Docker npm / yarn AWS CLI PowerShell tmux GNU Screen

Search all Terraform shortcuts interactively

Interactive Shortcut Finder

Main commands (5)

ShortcutActionWhat it does
terraform initPrepare your working directory for other commandsPrepare your working directory for other commands.
terraform validateCheck whether the configuration is validCheck whether the configuration is valid.
terraform planShow changes required by the current configurationShow changes required by the current configuration.
terraform applyCreate or update infrastructureCreate or update infrastructure.
terraform destroyDestroy previously-created infrastructureDestroy previously-created infrastructure.

All other commands (21)

ShortcutActionWhat it does
terraform consoleTry Terraform expressions at an interactive command promptTry Terraform expressions at an interactive command prompt.
terraform fmtReformat your configuration in the standard styleReformat your configuration in the standard style.
terraform force-unlockRelease a stuck lock on the current workspaceRelease a stuck lock on the current workspace.
terraform getInstall or upgrade remote Terraform modulesInstall or upgrade remote Terraform modules.
terraform graphGenerate a Graphviz graph of the steps in an operationGenerate a Graphviz graph of the steps in an operation.
terraform importAssociate existing infrastructure with a Terraform resourceAssociate existing infrastructure with a Terraform resource.
terraform loginObtain and save credentials for a remote hostObtain and save credentials for a remote host.
terraform logoutRemove locally-stored credentials for a remote hostRemove locally-stored credentials for a remote host.
terraform metadataMetadata related commandsMetadata related commands.
terraform modulesShow all declared modules in a working directoryShow all declared modules in a working directory.
terraform outputShow output values from your root moduleShow output values from your root module.
terraform providersShow the providers required for this configurationShow the providers required for this configuration.
terraform refreshUpdate the state to match remote systemsUpdate the state to match remote systems.
terraform showShow the current state or a saved planShow the current state or a saved plan.
terraform stateAdvanced state managementAdvanced state management.
terraform taintMark a resource instance as not fully functionalMark a resource instance as not fully functional.
terraform untaintRemove the 'tainted' state from a resource instanceRemove the 'tainted' state from a resource instance.
terraform versionShow the current Terraform versionShow the current Terraform version.
terraform workspaceWorkspace managementWorkspace management.
terraform -helpShow this help output, or the help for a specified subcommand.Show this help output, or the help for a specified subcommand..
terraform -versionAn alias for the "version" subcommand.An alias for the "version" subcommand..
📜 Source: HashiCorp Developer — Terraform CLI commands. The terraform -help output as published on HashiCorp Developer: main workflow commands first, then every other subcommand. Checked 2026-09-06. How we verify ›

Frequently Asked Questions

📄 View Printable Cheat Sheet — Download as PDF or print · 🧩 Combine with other tools

What is the Terraform workflow?

The basic workflow is: terraform init (initialize) → terraform plan (preview) → terraform apply (execute) → terraform destroy (cleanup).

What does terraform plan do?

terraform plan creates an execution plan showing what changes will be made to your infrastructure without actually applying them.

How do I import existing resources into Terraform?

Use 'terraform import resource_type.name resource_id' to bring existing infrastructure under Terraform management.

How do I format Terraform files?

Run 'terraform fmt' to automatically format all .tf files to the canonical style.

What's the fastest way to learn all Terraform shortcuts?

Print the Terraform cheat sheet and keep it next to your keyboard for the first week, then switch to active recall: open Shortcut Speedrun and practice Terraform shortcuts against the clock until they're automatic.

Can I combine Terraform shortcuts with other tools?

Yes — use My Stack to combine Terraform shortcuts with any other platform on this site into one printable reference, which is useful if your daily workflow spans several tools.

Browse shortcuts for 268 platforms

Explore All
🔧 Spotted an error or a missing shortcut? Suggest an edit on GitHub — every accepted fix goes live on this page, the API and the CLI.

The loop

terraform init downloads providers and modules and configures the backend; run it after cloning and after adding a provider. terraform fmt and terraform validate tidy and type-check the configuration without touching infrastructure, and belong in CI. terraform plan computes the changes and prints them — read every line, because a resource marked for replacement means downtime — and terraform apply executes them after a confirmation; plan -out=file then apply file guarantees the applied change is the one reviewed. terraform destroy removes everything the configuration manages.

State

The state file maps configuration to real resources. terraform state list shows what Terraform believes it manages, and state show prints one resource's attributes. terraform import [resource] [ID] brings an existing resource under management by adding it to state — write the configuration block first, import, then plan until the diff is empty. terraform output prints output values, with -json for scripts. Never edit the state file by hand; use the state subcommands, which lock and back it up.

Workspaces and remote state

terraform workspace list shows workspaces, which give one configuration several independent states (dev, staging, prod) in the same backend; workspace select switches. For a team, a remote backend with locking (S3 with DynamoDB, Terraform Cloud, GCS) is the first thing to configure, because two people applying against local state is how resources get orphaned.

🤖 Ask AI about Terraform shortcuts

Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"

ChatGPT Claude Perplexity Gemini Grok