# terraform / core / workflow
The Six Commands: Terraform Core Workflow
Terraform manages infrastructure as code through a small, disciplined set of commands. Each one has a single job — formatting, validating, planning, or applying — and together they form the loop every Terraform project runs on, from a first init to a final destroy.
Read Before You Write
Terraform never touches your infrastructure blindly. Every change passes through a preview stage first — that's the core discipline the workflow enforces: describe, then preview, then apply, never skip straight to the last step.
init · fmt · validate · plan
These four commands read your configuration and, at most, your provider APIs. None of them create, modify, or delete a single real resource.
apply · destroy
Only these two commands change actual infrastructure — and both stop to ask for typed confirmation before doing so, unless you pass -auto-approve.
The Six Commands
terraform init
Initializes a project: downloads provider plugins, pulls in modules, creates the .terraform/ directory, and configures the backend.
- run when
First use, after changing providers/backend, or after cloning a repo.
Initializing provider plugins... - Finding hashicorp/aws... Terraform has been successfully initialized!
terraform plan
Compares current infrastructure against your configuration and shows exactly what would be created, modified, or destroyed. Nothing is changed.
- mental model
"Here's what I'm going to do. Is it okay?"
+ aws_instance.web Plan: 1 to add, 0 to change, 0 to destroy.
terraform apply
Reads the configuration, generates a plan, asks for confirmation, then executes the changes for real.
- CI/CD
Skip the prompt with
terraform apply -auto-approve.
Do you want to perform these actions? Enter a value: yes
terraform destroy
Deletes every resource Terraform manages for this configuration. Asks for confirmation the same way apply does.
- caution
Use carefully, especially in production.
-auto-approveskips the prompt.
Destroy complete! Resources: 5 destroyed.
terraform fmt
Automatically rewrites your .tf files to Terraform's standard style — consistent spacing, aligned = signs, cleaner reviews.
resource "aws_instance" "web" { ami = "ami-123" instance_type = "t2.micro" }
terraform validate
Checks that your configuration is syntactically valid — required arguments, block structure, and references. It never contacts your cloud provider.
- tip
Run this before
planto catch mistakes early.
Success! The configuration is valid. Error: Missing required argument
The Typical Workflow
Format, then validate, then initialize. Cheap checks run before anything that touches a provider API.
Plan shows the diff between desired and actual state — your last chance to catch a mistake before it's real.
Apply executes the plan. Destroy, run only when the environment is truly done, tears it back down.
Quick Summary
| Command | Purpose | Changes Infrastructure? |
|---|---|---|
terraform init | Initialize project, download providers/modules | No |
terraform fmt | Format Terraform code | No |
terraform validate | Validate configuration syntax | No |
terraform plan | Preview proposed changes | No |
terraform apply | Create or update infrastructure | Yes |
terraform destroy | Delete managed infrastructure | Yes |