Commands Cheat Sheet

Evaluating engineering tools? Get the comparison in Google Sheets

(Perfect for making buy/build decisions or internal reviews.)

Most-used commands
Your email is safe thing.

Thankyou for your submission

We have sent the cheatsheet on your email!
Oops! Something went wrong while submitting the form.

Setup and Configuration

terraform init
Initialize a Terraform working directory, downloads providers and modules

terraform fmt
Reformat your configuration files to a canonical format and style

terraform validate
Validate the configuration files for syntax and internal consistency

Planning and Applying Changes

terraform plan
Show changes required by the current configuration

terraform apply
Apply the changes required to reach the desired state

terraform apply -auto-approve
Apply changes without interactive approval

terraform plan -out=planfile
Save the plan to a file for later execution

State Management

terraform state list
List resources in the state

terraform state show [resource]
Show details of a specific resource in the state

terraform state mv [source] [destination]
Move an item in the state

terraform state rm [address]
Remove an item from the state

terraform state pull
Output current state to stdout

terraform state push [path]
Update state from file

Workspace Management

terraform workspace list
List workspaces

terraform workspace select [name]
Select a workspace

terraform workspace new [name]
Create a new workspace

terraform workspace delete [name]
Delete a workspace

terraform workspace show
Show the name of the current workspace

Resource Management

terraform import [address] [ID]
Import existing infrastructure into Terraform

terraform destroy
Destroy all remote objects managed by a configuration

terraform taint [address]
Mark a resource instance as not fully functional

terraform untaint [address]
Remove the 'tainted' state from a resource instance

Module Management

terraform get
Download and update modules mentioned in the root module

terraform init -upgrade
Update all modules and providers

Output and Resource Inspection

terraform output
Show all outputs in the state file

terraform output [name]
Show a specific output from the state file

terraform graph
Generate a visual representation of dependencies

terraform show
Show the current state or a saved plan

terraform console
Interactive console for evaluating expressions