Skip to content

Terraform COMMANDS

Here is a list of some commonly used Terraform commands, along with a brief description and example for each:

  • terraform init: Prepare your working directory for other commands. Example: terraform init
  • terraform validate: Check whether the configuration is valid. Example: terraform validate
  • terraform plan: Show changes required by the current configuration. Example: terraform plan
  • terraform apply: Create or update infrastructure. Example: terraform apply
  • terraform destroy: Destroy previously-created infrastructure. Example: terraform destroy
  • terraform console: Try Terraform expressions at an interactive command prompt. Example: terraform console
  • terraform fmt: Reformat your configuration in the standard style. Example: terraform fmt
  • terraform force-unlock: Release a stuck lock on the current workspace. Example: terraform force-unlock LOCK_ID
  • terraform get: Install or upgrade remote Terraform modules. Example: terraform get
  • terraform graph: Generate a Graphviz graph of the steps in an operation. Example: terraform graph
  • terraform import: Associate existing infrastructure with a Terraform resource. Example: terraform import ADDRESS ID
  • terraform login: Obtain and save credentials for a remote host. Example: terraform login
  • terraform logout: Remove locally-stored credentials for a remote host. Example: terraform logout
  • terraform output: Show output values from your root module. Example: terraform output
  • terraform providers: Show the providers required for this configuration. Example: terraform providers
  • terraform refresh: Update the state to match remote systems. Example: terraform refresh
  • terraform show: Show the current state or a saved plan. Example: terraform show
  • terraform state: Advanced state management. Example: terraform state list
  • terraform taint: Mark a resource instance as not fully functional. Example: terraform taint ADDRESS
  • terrafrom untaint: Remove the ‘tainted’ state from a resource instance. Example: terrafrom untaint ADDRESS
  • terrafrom version: Show the current Terraform version. Example:terrafrom version

init

validate

plan

apply

destroy

console

fmt

force-unlock