Interview prep

Terraform Interview Questions

Terraform interviews centre on state management, module design and safe changes to live infrastructure.

Questions and answers

01What is Terraform state and why does it need remote storage?

State maps configuration to real resources. Remote backends with locking let a team share one source of truth and prevent two concurrent applies from corrupting it.

02Difference between count and for_each?

count indexes by integer, so removing a middle element re-indexes and destroys resources. for_each keys by a stable map or set key, so additions and removals are surgical.

03How do you bring an existing resource under Terraform?

terraform import, or an import block in newer versions, then write matching configuration until plan is clean.

04What is a module and how do you version it?

A reusable package of resources with inputs and outputs. Reference it from a registry or a Git tag and pin the version so consumers upgrade deliberately.

05How do you avoid destructive plans in production?

Review plans in CI, use lifecycle prevent_destroy on critical resources, separate state per environment, and apply behind approval.

How to answer these well

Interviewers are not grading recall — they are checking whether you've hit the failure mode the question describes. Anchor every answer to something you actually shipped or debugged with Terraform.

Say the trade-off out loud. "I'd use X here, but it costs Y under Z conditions" scores higher than a clean textbook definition every time.

Roles asking for Terraform

Related prep