Terraform 1 cheatsheet
Terraform 1: Core workflow
11 common Terraform 1 tasks.
Check the Terraform version
Print the Terraform version and the provider versions in use.
terraform version
Initialize a working directory
Download providers and modules and set up the backend. Run it first and after changing providers.
terraform init
Upgrade providers
Install the newest provider versions allowed by your version constraints.
terraform init -upgrade
Format the code
Rewrite configuration files into the canonical style, including subfolders.
terraform fmt -recursive
Validate the configuration
Check the configuration for syntax and consistency errors.
terraform validate
Save a plan to a file
Save the plan so you can apply exactly what you reviewed.
terraform plan -out=tfplan
Destroy all managed infrastructure
Delete everything the configuration manages.
terraform destroy
Caution: Deletes real resources and their data. Run terraform plan -destroy first and check the workspace.
Apply without confirmation
Skip the approval prompt, as CI pipelines do.
terraform apply -auto-approve
Caution: Changes are made without a chance to review. Use it only with a plan you have already reviewed.