Understanding Terraform Plan and Apply
Learn the core Terraform workflow: how plan previews changes and apply executes them, the heart of safe infrastructure as code.
Understanding Terraform Plan and Apply is a free DevOps Bootcamp lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Core Workflow
Terraform's daily loop is simple: write config, run plan to preview, then apply to make it real. Mastering plan and apply is the heart of safe IaC.
What plan Does
terraform plan diffs three things — your config, the current state, and the real infrastructure — then shows the actions to reconcile them, changing nothing.
terraform planReading the Symbols
Plan output uses symbols: + creates, - destroys, ~ updates in place, and -/+ means destroy then recreate (a replacement).
A Sample Plan
Adding an S3 bucket produces a plan like this one — one resource to add.
Terraform will perform the following actions:
# aws_s3_bucket.logs will be created
+ resource "aws_s3_bucket" "logs" {
+ bucket = "my-logs"
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.known after apply
Some values, like generated IDs or IPs, can't be predicted yet. Terraform marks them known after apply — filled in once the resource actually exists.
Saving a Plan
You can save a plan to a file and apply that exact plan later — guaranteeing apply does precisely what you reviewed, nothing more.
terraform plan -out=tfplan
terraform apply tfplanWhat apply Does
terraform apply executes the planned actions through provider APIs, then updates the state file. Without a saved plan, it shows the plan and asks first.
terraform applyThe Confirmation Prompt
By default apply pauses and asks you to type yes to proceed. Automation can use -auto-approve — but only on a plan you've already reviewed.
Dependency Ordering
Terraform builds a dependency graph and applies resources in the right order — creating a security group before the instance that references it, automatically.
Idempotency
Terraform is idempotent: apply again with nothing changed and you get "No changes." Your config is the source of truth, so repeated applies converge.
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.Best Practices
Always run plan before apply and review it like a code review — watch for destroys. Use saved plans in CI; never hand-edit state.
Quick Check
Test your plan/apply knowledge.
Recap
Recap: the plan/apply loop is Terraform's core — plan diffs config, state, and reality; save plans with -out; apply runs in dependency order; and it's idempotent.
Frequently asked questions
Is the “Understanding Terraform Plan and Apply” lesson free?
Yes — the full text of “Understanding Terraform Plan and Apply” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.
What will I learn in “Understanding Terraform Plan and Apply”?
Learn the core Terraform workflow: how plan previews changes and apply executes them, the heart of safe infrastructure as code. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Understanding Terraform Plan and Apply” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Introduction to IaC and Terraform
- Installing Terraform and CLI Basics
- Your First Terraform Configuration
- Understanding Terraform Plan and Apply