Terraform Cheat Sheet

Every Terraform command in the library, on one page. Search, filter by category, or jump to a full command reference for detailed examples.

CommandSyntaxDescription
terraform initterraform initInitializes a working directory — downloads providers and modules, and sets up the backend.
terraform planterraform plan [-out=<file>]Shows what changes Terraform would make without actually applying them.
terraform applyterraform apply [<plan-file>]Applies the changes required to reach the desired state described in your configuration.
terraform destroyterraform destroyDestroys all resources managed by the current Terraform configuration.
terraform fmtterraform fmt [-recursive]Rewrites configuration files to a canonical format and style.
terraform validateterraform validateChecks whether a configuration is syntactically valid and internally consistent.
terraform state listterraform state listLists every resource currently tracked in the state file.
terraform state showterraform state show <resource>Shows the current state attributes of a single resource.
terraform importterraform import <resource-address> <id>Brings an existing, manually-created resource under Terraform management by adding it to the state.
terraform outputterraform output [<name>]Prints the values of output variables defined in the configuration.