Terraform Cheat sheet

December 27, 2023

Gokul Deepak S

Terraform Cheatsheet with pdf. You can download Terraform Cheatsheet pdf with all Terraform CLI commands needed.

The mentioned list is the most used Terraform commands. If you need more additional information on each of the commands you can find it in the below link.

  • terraform version : Get terraform version
  • terraform -help : Get the list of all commands with descriptions.
  • terraform init : Initalizes terraform working directory
  • terraform init -migrate-state : Reconfigure the backend and will migrate the backend
  • terraform validate : Validates syntax and arguments of terraform files
  • terraform plan : Runs execution plan
  • terraform plan -out=pathofplan : Runs execution plan and saves in a file
  • terraform plan -destroy : Runs an execution plan for destroy
  • terraform apply : Create and update infrastructure
  • terraform apply -auto-approve : Updates infrastructure without expecting ‘yes’
  • terraform apply -var=”instance_type=t2.micro” : Runs apply with value for the variable
  • terraform apply -var-file=”varfile.tfvars” : Runs apply with variable values mentioned in the file 
  • terraform apply filename : Runs apply over the plan output created in file
  • terraform apply -target=”aws_instance.this” : Runs apply only to particular resource
  • terraform apply -parallelism=5 : Creates resources paralley. Default value is 10
  • terraform destroy : Destroys all resources in statefile
  • terraform destroy –auto-approve : Destroys infrastructure without expecting ‘yes’
  • terraform destroy -target=”aws_instance.this” : Destroys particular resource
  • terraform fmt : Formats terraform code
  • terraform fmt –recursive : Formats terraform code including subdirectories
  • terraform fmt  –diff : Displays difference after formating
  • terraform get : Downloads modules

About the author

Gokul Deepak is a DevOps engineer focused on building reliable cloud systems through automation, observability, and disciplined infrastructure design. He shares practical insights from real-world production environments, helping engineers build systems that scale with clarity and confidence.

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments