Loading

Quipoin Menu

Learn • Practice • Grow

terraform / Terraform Init and Plan
tutorial

Terraform Init and Plan

The first two commands you'll use in any Terraform project are terraform init and terraform plan. They set up your working directory and let you preview changes.

terraform init

Initializes a Terraform working directory. It:
  • Downloads provider plugins specified in the configuration.
  • Sets up the backend (local or remote).
  • Installs modules (covered later).
Run it in a directory containing .tf files:
terraform init
You must run this before any other command. Re‑run it if you change provider versions or backends.

terraform plan

Creates an execution plan, showing what Terraform will do without actually making changes. It compares the current state (from terraform.tfstate) with your configuration.
terraform plan
Output shows:
  • + create new resource
  • - destroy existing resource
  • ~ update in‑place
  • -/+ replace (destroy then create)

Example Workflow

Create a file main.tf with content:
terraform {
required_providers {
random = {
source = "hashicorp/random"
}
}
}

resource "random_string" "pet" {
length = 6
special = false
}
Now run:
terraform init
terraform plan
You'll see a plan showing one resource to add.

Saving Plans

You can save the plan to a file:
terraform plan -out=myplan.tfplan
Then apply exactly that plan: terraform apply myplan.tfplan.

Destroy Plan

To see a plan that destroys all resources:
terraform plan -destroy


Two Minute Drill
  • terraform init downloads providers and sets up backend.
  • terraform plan previews changes without applying.
  • Plan symbols: + create, - destroy, ~ update, -/+ replace.
  • Save plan to file for later apply.
  • Always run init before plan.

Need more clarification?

Drop us an email at career@quipoinfotech.com