DevOpsLesson
DevOpsLesson

Free, comprehensive DevOps tutorials and learning roadmaps. Master Docker, Kubernetes, CI/CD, and more.

Stay Updated

Get notified about new tutorials and features.

Tutorials

  • What is DevOps?
  • Docker Tutorial
  • Terraform Tutorial
  • CI/CD Pipeline
  • All Tutorials

Roadmaps

  • DevOps Engineer
  • Cloud Engineer
  • SRE Path
  • All Roadmaps

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 DevOpsLesson. All rights reserved.

DOCKERKUBERNETESTERRAFORMAWSCI/CDLINUXGITDEVOPS ROADMAPCLOUD ROADMAPSRE ROADMAPGIT CHEATSHEETDOCKER CHEATSHEETK8S CHEATSHEETTF CHEATSHEETLINUX CHEATSHEETDOCKERFILE LINTERYAML VALIDATORCRON PARSERREGEX TESTER

Terraform Tutorial

Introduction to Terraform
Installing Terraform
The Terraform Core Workflow
Terraform Variables and Outputs
Terraform State and Backends
Terraform Modules
Terraform Data Sources
Terraform Count and for_each
Terraform Expressions and Functions
Terraform Dynamic Blocks
Terraform Workspaces
Terraform with AWS
Terraform Provisioners
Terraform CI/CD Pipeline
Terraform Security

The Terraform Core Workflow

PreviousPrev
Next

The four commands that power every Terraform project, init, plan, apply, and destroy. Learn the complete workflow loop used by every DevOps engineer managing infrastructure as code.

The Four Commands That Power Terraform

No matter how large or complex your infrastructure becomes, every Terraform workflow follows the same simple loop built around four commands:

CommandWhat it doesWhen to run it
terraform initDownloads providers, sets up the backendOnce per project, and after any provider/backend change
terraform planShows exactly what will change, no side effectsEvery time before applying
terraform applyCreates, updates or deletes infrastructureAfter reviewing and approving the plan
terraform destroyRemoves all managed resourcesWhen tearing down an environment

This loop, write → init → plan → apply: is the heartbeat of Infrastructure as Code. You will repeat it for the entire lifetime of every Terraform project.

The Workflow in Practice

# 1. Write your configuration in .tf files, then initialise
terraform init

# 2. Preview every change before it happens
terraform plan

# 3. Apply after reviewing the plan output
terraform apply

# 4. Tear down when done
terraform destroy

The critical thing that separates Terraform from clicking through a cloud console is the plan step. Before any infrastructure changes, you see a precise diff, every resource to be created (+), updated (~), replaced (-/+), or deleted (-). Nothing is a surprise.

What This Section Covers

Each command has its own dedicated page with complete detail, real examples, and common pitfalls:

  • terraform init: What init does internally, provider downloads, backend setup, and the lock file
  • terraform plan: Reading the execution plan, understanding resource symbols, saving plan files, and targeting
  • terraform apply: Applying changes safely, auto-approve in CI/CD, and what happens during apply
  • terraform destroy: Safely tearing down environments and partial destroys

Start with terraform init →

PreviousPrev
Next

Continue Learning

Introduction to Terraform

Learn what Terraform is, how Infrastructure as Code works, why it beats clicking through cloud consoles, and how Terraform compares to Ansible, CloudFormation and Pulumi.

12 min read·Easy

Installing Terraform

Step-by-step guide to installing Terraform on macOS, Linux and Windows using the official HashiCorp package managers. Verify the install and run your first real Terraform configuration.

10 min read·Easy

terraform init

Learn exactly what terraform init does, downloading providers, setting up backends, creating the lock file, and how to use init flags like -upgrade and -reconfigure.

10 min read·Easy

Explore Related Topics

AW

AWS Tutorials

Provision AWS infrastructure with Terraform

CI

CI/CD Tutorials

Run terraform plan/apply in CI pipelines

Try the Tool

YAML Validator

Validate Terraform and Kubernetes YAML configs before applying.

On This Page

The Four Commands That Power TerraformThe Workflow in PracticeWhat This Section Covers