Skip to main content

Terraform CLI Cheat Sheet 2026 — Quick CLI Command Reference

Terraform CLI Cheat Sheet 2026 — Quick Command Reference

Terraform CLI Cheat Sheet is the complete quick-reference of Terraform CLI commands grouped by function. Copy any command with one click and find what you need with Ctrl+F in under 3 seconds.

Init & Configuration

Action Command Useful flags
Initialize a new or existing Terraform configuration
terraform init
Verify that the configuration files are syntactically valid
terraform validate
Format configuration according to Terraform language style conventions
terraform fmt
List required providers
terraform providers
Show Terraform version and platform info
terraform version

Plan & Apply

Action Command Useful flags
Generate and show an execution plan
terraform plan
Build or change infrastructure
terraform apply
Save plan to file
terraform plan -out=<path>
-out=<path>
Apply saved plan file
terraform apply <planfile>
Apply with auto-approve
terraform apply -auto-approve
-auto-approve
Create destroy plan
terraform plan -destroy
-destroy
Apply destroy plan
terraform apply -destroy -auto-approve
-destroy -auto-approve
Plan specific resource
terraform plan -target=<resource>
-target=<resource>
Apply specific resource
terraform apply -target=<resource>
-target=<resource>
Plan with variable file
terraform plan -var-file=<file>
-var-file=<file>

State Management

Action Command Useful flags
No commands detected for this group.

Workspaces

Action Command Useful flags
No commands detected for this group.

Modules

Action Command Useful flags
Initialize configuration with modules
terraform init -upgrade <path>
-upgrade -reconfigure
Initialize from a module source
terraform init -from-module=<source> <target-dir>
-from-module
Validate module configuration
terraform validate -no-color <path>
-no-color
Format module files recursively
terraform fmt -recursive <path>
-recursive -diff

Import & Move

Action Command Useful flags
No commands detected for this group.

Variables & Outputs

Action Command Useful flags
Plan with variable assignment
terraform plan
-var '<name>=<value>'
Apply with variable assignment
terraform apply
-var '<name>=<value>'

Destroy & Cleanup

Action Command Useful flags
Destroy all infrastructure in the current directory
terraform destroy
Preview resources to destroy
terraform plan -destroy
-destroy
Apply destruction without separate plan
terraform apply -destroy
-destroy
Destroy specific resource only
terraform destroy -target=<resource-address>
-target=<resource-address>
Reinitialize backend configuration
terraform init -reconfigure
-reconfigure

⚠️ Dangerous / Destructive Commands

These commands are irreversible. Verify your environment (dev/staging vs prod) before running them.

Action Command Warning
⚠️ Plan
terraform plan -destroy
Irreversible — verify the target before running
⚠️ Apply
terraform apply -destroy -auto-approve
Irreversible — verify the target before running
⚠️ Destroy ⚠️
terraform destroy
Irreversible — verify the target before running
⚠️ Plan
terraform plan -destroy
Irreversible — verify the target before running
⚠️ Apply
terraform apply -destroy
Irreversible — verify the target before running
⚠️ Destroy ⚠️
terraform destroy -target=<resource-address>
Irreversible — verify the target before running

FAQ — Frequently Asked Questions

What is the difference between Init & Configuration and Plan & Apply?

Each group in this Terraform CLI cheat sheet covers a distinct area. Init & Configuration focuses on its specific scope, while Plan & Apply and the remaining groups cover networking, storage, security and diagnostics respectively.

How do I check the installed Terraform CLI version?

Run the version command (usually terraform version or terraform --version). The output shows the client and, when applicable, the server version.

Why does Terraform CLI return ‘permission denied’?

A ‘permission denied’ error in Terraform CLI usually means the current user lacks sufficient privileges or credentials are not configured. Check: (1) assigned IAM/RBAC roles, (2) an active authentication context via the corresponding login command.

How do I filter Terraform CLI output by status or name?

Use flags such as --filter, --selector or --query depending on the tool. You can also pipe into grep or jq to process JSON:

terraform list | grep RUNNING

What is the fastest way to debug a Terraform CLI error?

Add the verbose flag (--verbose, -v or --debug) to the failing command. This reveals the underlying HTTP/API calls and the full error response body.

Official sources & references

Commands cross-checked against vendor documentation and high-authority repositories: