Terraform Interview Guide
A focused path through Terraform interview prep — provider workflow mechanics, module design, and state management, the areas this bank covers in depth.
Introduction
This guide covers exactly what this bank's 22 Terraform questions actually go deep on: the day-to-day mechanics of running Terraform in a team (providers, the CLI workflow, imports, environments), how to structure modules so they scale past one person's laptop, and — the area with the most genuine weight — the judgment calls around state that separate someone who's run terraform apply from someone who's operated Terraform against production infrastructure other people depend on.
It is not a Terraform-from-zero tutorial (there's no beginner-difficulty content here — the floor is intermediate), and it's not a general infrastructure-as-code philosophy guide either. For broader, tool-agnostic IaC practices — drift detection design, module design principles that apply beyond Terraform specifically, Terraform-vs-Pulumi-vs-cloud-native trade-offs — this bank has a separate, related infrastructure-as-code category worth working through alongside this guide, not instead of it.
Who This Guide Is For
This bank's Terraform questions map to DevOps Engineer, Senior DevOps, and Staff/Principal levels, with a single DevSecOps-relevant question (state file secrets exposure) — that's the honest scope, not a rounder-sounding list. There is currently no Junior DevOps, SRE, Platform Engineer, or Cloud Engineer coverage specific to Terraform in this bank; if you're preparing for one of those roles, the reasoning here (especially the state-management judgment calls) still transfers, but don't expect dedicated content at that level yet.
Concretely: if you're expected to run Terraform changes against shared infrastructure and reason about what happens when something goes wrong — a corrupted state file, an unexpected destroy-and-recreate, a breaking module change reaching thirty consumers — this guide is built for exactly that interview.
Prerequisites
Before working through this guide, you should already be comfortable with:
- Core Terraform vocabulary: providers, resources, variables/outputs, and what
plan/applyactually do. - Having run Terraform yourself at least a handful of times — this bank assumes familiarity with the basic workflow, not first exposure to it.
- Basic version control practices (this bank's module and CI/CD questions assume you understand PRs, tagging, and release practices in general, even before applying them to Terraform specifically).
- General production-safety instincts — the instinct to ask "what does this actually change" before running something against shared infrastructure.
Learning / Interview Path
Three stages, sequenced by how the actual content clusters — work through them in order.
- Providers (9 questions). Despite the subcategory name, this is really the CLI-and-workflow-mechanics stage: provider version pinning and lock-file checksums, importing a resource that was created manually, running the same resource across multiple regions with provider aliases, and the specific migration risk of converting
counttofor_each. This is intermediate-heavy (7 of 9) and deliberately first — it's the operational fluency everything else assumes. - Modules (4 questions). Once the day-to-day mechanics are solid, move to how Terraform code is actually structured at team scale: registry versus Git-tag module distribution, designing a module differently depending on who consumes it, and — the hardest question in this stage — how you'd actually ship an urgent fix to a shared module without breaking the thirty other teams depending on it. Small in count, but each question is a genuine trade-off discussion, not a syntax check.
- State (9 questions). This is where the bank's real weight sits — 7 of 9 questions here are advanced difficulty, and it shows: state file backup and recovery, blocking destructive applies in CI/CD,
create_before_destroysemantics, monolithic versus micro-stacks, cross-stack coupling viaterraform_remote_state, and the specific danger of secrets leaking into state. Doing this stage last means the workflow fluency from stage 1 and the structural thinking from stage 2 are both already in place — state questions in this bank routinely assume both.
Key Concepts
- A
terraform plandiff can come from your code, from drift, or from the provider itself — and they need different responses. A data source that resolves to "the latest AMI" can produce a diff with zero code change; state drift from a manual console edit produces a different kind of diff; and neither is a bug in Terraform. Diagnosing which one you're looking at is a recurring skill in this bank. countandfor_eachkey state fundamentally differently.countindexes numerically;for_eachindexes by map/set key. Switching between them withoutterraform state mv(or amovedblock) makes Terraform see entirely different resources — destroy-and-recreate, not an in-place change.- State holds real secrets in plaintext by default. Any sensitive value passed as a resource argument lands in the state file whether or not you mark it
sensitivein your own outputs —sensitive = trueonly affects what's displayed, not what's stored. This is one of the more consequential, easy-to-miss facts in Terraform. -targetandterraform state rmare both scalpels, not fixes. Both let you act on one resource in isolation, and both carry real risk (a-targetapply can leave the rest of the plan stale;state rmremoves a resource from management, it doesn't delete the resource itself) — this bank tests whether you know the difference between "the fast way" and "the safe way."- A destroy-and-recreate plan (
-/+) on a stateful resource is not routine. Terraform's own annotation tells you exactly which attribute forced it — reading that before runningapplyis the difference between a safe change and a production incident.
Interview Focus
- DevOps Engineer: Can you run the standard workflow confidently and diagnose the common CLI failures — a lock-file mismatch, a stuck state lock, an unpinned provider that silently upgraded?
- Senior DevOps: Can you reason about consequences — what a given change actually does to production state, why a plan is showing what it's showing, and how to structure modules so a change doesn't ripple unpredictably to other teams?
- DevSecOps: The one security-tagged question in this bank (state file secrets exposure) is representative of the actual concern: not "is Terraform secure," but "what ends up in this state file, who can read it, and what do you do about it."
- Staff / Principal: The state-management questions at this level are architectural — monolithic versus micro-stacks, cross-stack coupling trade-offs, designing CI/CD to structurally prevent a destructive apply. These are judgment calls with real trade-offs on both sides, not a single correct answer.
Across every level, naming the actual mechanism — terraform state mv, a moved block, -refresh-only, create_before_destroy — reads far stronger than describing the idea without the vocabulary.
Scenario & Troubleshooting Focus
Terraform troubleshooting in this bank rarely has a one-line fix. A checksum mismatch, an unexpected recreate, a stuck state lock — each requires reading the specific error/plan output carefully before acting, because the wrong fast fix (force-unlocking a lock that's actually still held, or letting an unexplained -/+ through to apply) can cause real damage to shared infrastructure. That's deliberate: Terraform questions test restraint and diagnosis at least as much as they test knowing the fix.
The full set of Terraform troubleshooting questions is at Terraform Troubleshooting Questions, and the trade-off-heavy scenario questions are at Terraform Scenario Questions. Practice these by first writing down exactly what you'd check in the plan output or state before proposing a fix — that's the specific reasoning this bank's questions are built to evaluate.
Common Mistakes
- Running
applyon an unexplained-/+without reading which attribute forced replacement. Terraform tells you directly, via a# forces replacementannotation — skipping that check on a stateful production resource is the single riskiest habit this bank's state questions are built to catch. - Treating
-targetorstate rmas routine tools rather than deliberate exceptions. Both are legitimate in the right, narrow circumstance; reaching for them as a default fix reads as not understanding what they actually risk. - Assuming
sensitive = truekeeps a value out of the state file. It only suppresses console/log output — the plaintext value is still in state. Conflating "hidden from output" with "not stored" is a specific, common misconception. - Switching
counttofor_each(or the reverse) without a state migration plan. Withoutterraform state mvor amovedblock, Terraform will propose destroying and recreating every instance — a candidate who doesn't anticipate this is missing a core piece of how Terraform's state addressing actually works. - Proposing a broad architectural rewrite when the real answer is a specific, existing mechanism. Several state questions in this bank have a precise, mechanism-level correct answer (a
movedblock,-refresh-only,create_before_destroy) — reaching immediately for "redesign the whole state structure" reads as not knowing the direct tool.
Recommended Preparation Path
This bank is small (22 questions) — a multi-week schedule would be filler. A more honest plan:
- First session: The eight Must Practice questions below — a genuine cross-section of providers, modules, and state, doable in under two hours.
- Second session: Whichever of Providers, Modules, or State felt weakest, worked through in full.
- Third session: The remaining two subcategories, in the Learning Path order above.
- Before the interview: Revisit Common Mistakes and the troubleshooting/scenario links — the state-management judgment calls are where this bank's real signal concentrates.
References
Practice Questions
The list below is generated live from the current Terraform question bank — nothing here is a fixed list that goes stale as new questions are added. Start with Must Practice for a cross-section of all three subcategories, then use the groupings below to focus your remaining time.
Must Practice
Short on time? This is a deliberately small, representative cross-section — work through these first.
- terraform plan fails with Error acquiring the state lock — how do you diagnose whether it's a genuine concurrent run or a stale lock?Intermediate
- A production database was created manually through the AWS console years ago — how would you bring it under Terraform management without recreating it?Intermediate
- Should you use Terraform workspaces or separate directories/state files to manage dev, staging, and production — what's the actual trade-off?Intermediate
- Your team has copy-pasted the same VPC Terraform configuration into six different repositories. Design a module structure and versioning strategy to fix that.Intermediate
- How would you handle a breaking change to a shared Terraform module that genuinely needs to reach all consumers within a specific timeframe, like a security fix?Advanced
- A database password is passed as a resource argument in Terraform — does marking the variable sensitive actually protect it in the state file?Advanced
- terraform plan shows a production RDS instance will be destroyed and recreated after a change you thought was trivial. What would you investigate before running apply?Advanced
- A single Terraform state file managing an entire environment's infrastructure takes 10 minutes to plan and any change risks touching everything — how would you split it?Advanced
By Subcategory
What each area of Terraform interview prep actually covers, and how much of it exists in the bank.
- A production database was created manually through the AWS console years ago — how would you bring it under Terraform management without recreating it?
- Should you use Terraform workspaces or separate directories/state files to manage dev, staging, and production — what's the actual trade-off?
- terraform plan fails with Error acquiring the state lock — how do you diagnose whether it's a genuine concurrent run or a stale lock?
- How would you handle a breaking change to a shared Terraform module that genuinely needs to reach all consumers within a specific timeframe, like a security fix?
- Your team has copy-pasted the same VPC Terraform configuration into six different repositories. Design a module structure and versioning strategy to fix that.
- What would make you choose a private Terraform module registry over Git-tag-based module sourcing, or vice versa?
- A single Terraform state file managing an entire environment's infrastructure takes 10 minutes to plan and any change risks touching everything — how would you split it?
- A database password is passed as a resource argument in Terraform — does marking the variable sensitive actually protect it in the state file?
- terraform plan shows a production RDS instance will be destroyed and recreated after a change you thought was trivial. What would you investigate before running apply?
Prepare by Interview Level
These aren't just counts — each one is a curated preparation path for that specific role. Pick the level you're actually interviewing for.
By Difficulty
Work upward if you're building from fundamentals, or jump straight to the difficulty an interview at your level will actually probe.
By Question Type
Practice one specific skill at a time — troubleshooting, architecture trade-offs, head-to-head comparisons, and more.
Related Guides
If your interview also covers AWS or Kubernetes, both guides are natural companions — most of this bank's Terraform questions reason about AWS resources specifically, and Terraform-managed Kubernetes clusters raise their own state-and-module questions worth preparing alongside these.
Last updated August 23, 2026 · Last reviewed August 23, 2026