7 Terraform commands you should know

7 Terraform commands you should know

  1. terraform apply -refresh-only command creates a plan whose goal is only to update the Terraform state and any root module output values to match changes made to remote objects outside of Terraform.

  2. terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style.

  3. terraform import command used to bring existing resources to terraforms control. Note to use this command, you must first create a configuration file for the existing resource first, then run terraform import name of resource

  4. terraform workspace new command is used to create a new workspace to use for operations.

  5. terraform workspace select command is used to choose a different workspace to use for further operations.

  6. terraform show command is used to provide human-readable output from a state or plan file. This can be used to inspect a plan to ensure that the planned operations are expected, or to inspect the current state as Terraform sees it.

  7. terraform login command can be used to automatically obtain and save an API token for Terraform Cloud, Terraform Enterprise, or any other host that offers Terraform services.