Check your Terraform intstallation in your local computer:
terraform --version
Initialize a working directory which contains Terraform configuration files:
terraform init
Adjust the configuratation files in canonical format and style in current directory:
terraform fmt
Adjust the configuratation files in canonical format and style in current directory and subdirectories:
terraform fmt -recursive
Runs checks that verify whether a configuration is syntactically valid and internally consistent:
terraform validate
Runs checks that verify whether a configuration is syntactically valid and internally consistent and shows in JSON format:
terraform validate -json
Create an execution plan:
terraform plan
Create an execution plan in a seperated file:
terraform plan -out=tfplan
Apply the pre-determined execution plan generated by terraform plan:
terraform apply
Apply the pre-determined execution plan without confirming:
terraform apply -auto-approve
Apply the pre-determined execution plan from the generated plan file:
terraform apply "tfplan"
Destroy all resources based off of what's in state file:
terraform destroy
Destroy a specefic or targeted resource:
terraform destroy -target=azurerm_virtual_machine.test
List of all resources incl. modules:
terraform state list
Shows the state or info about a resource:
terraform state show <resource-name>
Pull the remote state into the local state:
terraform state pull > terraform.tfstate
Refresh the state:
terraform refresh
Generate an .svg format image from your deployed resources:
terraform graph | dot -Tsvg > graph.svg
Shows all outputs:
terraform output
Shows a specefic output:
terraform output <output-name>
Shows all outputs in json format:
terraform output -json
Create a new workspace:
terraform workspace new <workspace-name>
Switch to a workspace:
terraform workspace select <workspace-name>
List all workspaces:
terraform workspace list