Terraform Interview Questions and Answers

Real scenario-based questions, a free 17-page Terraform guide, and practice exercises — no cloud account required to get started.

Free Terraform interview questions

A free sample — one beginner, one intermediate, one advanced — with the full answer shown below each question.

BeginnerWhat does `terraform destroy` do, and what precautions matter before running it?

It tears down every resource currently tracked in the state file. Before running it: confirm you're pointed at the right state/workspace (a `dev` state and `prod` state should never be ambiguous), and run `terraform plan -destroy` first so you see the full list of what's about to be deleted.

AdvancedChanging one attribute on a resource in your Terraform config causes plan to show a full destroy-and-recreate instead of an in-place update. Why does this happen, and what do you check?

Some resource attributes are immutable at the provider/API level (like an EC2 instance's availability_zone) — changing them can't be done in-place, so Terraform must destroy and recreate the resource entirely. Check the provider documentation for that resource to see which attributes force replacement, and plan around that (e.g., using create_before_destroy lifecycle rules to avoid downtime during the swap).

IntermediateWhat's the purpose of a .tfvars file, and why keep it separate from the main .tf configuration?

A .tfvars file supplies actual values for declared variables (e.g., environment = "production"), kept separate so the same reusable configuration can be applied with different .tfvars per environment (dev.tfvars, prod.tfvars) without duplicating or editing the core logic each time.

Learn Terraform in depth, free to start

A 17-page guide built against a real local Docker daemon — real state and drift, a real forced replacement from a tfvars change, and a real module written, called twice, and folded into state with state mv. The first page is free for everyone.

See the full 17-page Terraform guide →

Practice Terraform for real, no cloud account needed

Import a hand-made resource into state, force a wedged instance to rebuild with -replace, or untangle a dependency cycle between two security groups — all graded on real Terraform CLI behavior.

Try the Terraform practice exercises →

Terraform interview FAQ

What are the most commonly asked Terraform interview questions?

Interviewers usually describe a state problem — a dependency cycle, a plan that wants to destroy and recreate something it shouldn't, a lock left behind by a crashed run — and ask how you'd diagnose and fix it, rather than asking you to define a resource block from memory.

Do I need AWS, Azure, or GCP experience to answer Terraform questions?

Some cloud familiarity helps since most real Terraform code targets a specific provider, but the core skill being tested — state management, module design, plan/apply safety — transfers across providers. Many practice setups (including this site's) run entirely against a local Docker daemon instead.

What's the difference between Terraform and Ansible?

Terraform provisions infrastructure (creating a VM, a VPC, a database) and is declarative and state-based. Ansible configures what's already running (installing packages, managing config files) and is typically agentless and procedural. Most real pipelines use both — Terraform to build, Ansible to configure.

How do I practice Terraform without a cloud account?

Work through fix-the-config exercises and simulated-terminal incidents graded on real Terraform CLI output first — importing a resource, resolving a dependency cycle, handling drift — without needing a cloud account or paying for anything.

Starting from zero? Read the step-by-step DevOps career roadmap →

The rest of the guide is waiting.

Create a free account to track your progress through the guide, pass the end-of-page quizzes, and take a full-length Infrastructure as Code readiness check.