Terraform Interview Questions
Infrastructure as code, the state file & remote backends, state locking, the init/plan/apply workflow, providers, resources & modules, variables & outputs, count vs for_each, workspaces and drift management.
61 questions
Popular Searches
1. What is Terraform and what problem does infrastructure as code solve?
easyIaC Fundamentals 5 mins2. What is the difference between Terraform and configuration tools like Ansible?
mediumTooling Comparison 6 mins3. What is declarative vs imperative infrastructure and where does Terraform fit?
mediumIaC Concepts 6 mins4. What is the Terraform state file and why is it important?
easyState Management 5 mins5. Why should you use remote state in Terraform and how does a backend work?
mediumBackends 6 mins6. What is state locking in Terraform and why does it matter?
mediumState Management 6 mins7. What is the Terraform workflow with init, plan, and apply?
easyCore Workflow 6 mins8. What does terraform plan do and why is it important before apply?
easyCore Workflow 6 mins9. What are providers in Terraform and how do they work?
mediumProviders 7 mins10. What are resources and data sources in Terraform?
easyCore Concepts 5 mins11. What are input variables, output values, and locals in Terraform?
mediumConfiguration 6 mins12. What are Terraform modules and why do you use them?
mediumModules 6 mins13. What is the difference between a root module and a child module in Terraform?
easyModules 5 mins14. How does Terraform handle dependencies between resources?
mediumDependency Graph 6 mins15. What is the difference between count and for_each in Terraform?
mediumMeta-Arguments 6 mins16. What are provisioners in Terraform and why are they a last resort?
mediumProvisioners 6 mins17. What is terraform import and when do you use it?
mediumState Management 6 mins18. What is the difference between terraform taint and terraform replace?
mediumResource Lifecycle 6 mins19. How do Terraform workspaces work and when should you use them?
mediumState Management 6 mins20. What is drift in Terraform and how do you detect and fix it?
mediumState Management 6 mins21. How do you manage secrets and sensitive values in Terraform?
hardSecurity 7 mins22. What is the difference between terraform refresh and terraform plan?
mediumState Management 6 mins23. How does Terraform handle resource lifecycle with create_before_destroy and prevent_destroy?
hardResource Lifecycle 7 mins24. What are dynamic blocks in Terraform and when are they useful?
mediumConfiguration Language 6 mins25. How do you structure Terraform code for multiple environments?
mediumProject Structure 7 mins26. What is a Terraform backend and what are the common backend types?
mediumState Management 7 mins27. How does terraform destroy work and how do you prevent accidental destruction?
mediumLifecycle Management 7 mins28. What is the difference between Terraform and CloudFormation?
mediumIaC Tooling 6 mins29. What are common Terraform best practices for team collaboration?
mediumCollaboration 7 mins30. How do you test and validate Terraform code?
mediumTesting 7 mins31. How do you refactor Terraform code without destroying and recreating resources?
hardState Operations 8 mins32. How do you debug a Terraform run that fails inside a provider?
hardDebugging 8 mins33. What does .terraform.lock.hcl do and how do you manage provider checksums across platforms?
hardSupply Chain 8 mins34. How do you enforce guardrails on Terraform changes with policy as code?
hardGovernance 9 mins35. A single Terraform state has grown huge and plans are slow. How do you split it, and why is -target a last resort?
hardArchitecture 9 mins36. How do you use variable validation, preconditions, postconditions and check blocks in Terraform?
hardValidation 9 mins37. Why does Terraform say a value "will be known only after apply", and how do you work with unknown values?
hardPlan Semantics 8 mins38. How do you safely upgrade a Terraform provider across a breaking major version?
hardUpgrades 8 mins39. How do you run Terraform in CI/CD without storing long-lived cloud credentials?
hardCI/CD Security 9 mins40. How do you debug complex HCL expressions, and when do you use try, can and type conversion functions?
mediumHCL Expressions 8 mins41. The provider has no resource for what you need. What are your options and their trade-offs?
hardExtensibility 9 mins42. Your Terraform state is corrupted, lost, or no longer matches reality. How do you recover?
hardIncident Recovery 9 mins43. A Terraform run was killed mid-apply and now every plan fails with a state lock error. What do you do?
hardState Operations 9 mins44. What is the difference between an import block and the terraform import command?
mediumState Operations 8 mins45. How would you build continuous drift detection for Terraform, and what does a refresh-only plan actually do?
hardDrift & Operations 9 mins46. Why can removing one item from a Terraform list destroy several resources, and how do stable for_each keys prevent it?
hardMeta-Arguments 9 mins47. How do you version and pin Terraform modules, and why does a Git branch source cause trouble?
mediumModules 8 mins48. How do you manage resources in two regions or two accounts from one Terraform configuration?
mediumProviders 8 mins49. Why should a reusable module declare configuration_aliases instead of its own provider block?
hardModules 8 mins50. When does Terraform actually read a data source, and why does that sometimes break a plan?
hardData Sources 9 mins51. When is lifecycle ignore_changes the right answer, and when is it hiding a real problem?
mediumLifecycle 8 mins52. What does replace_triggered_by do, and how is it different from tainting a resource?
hardLifecycle 8 mins53. Does marking a variable sensitive keep it out of the state file? What actually protects secrets in Terraform?
hardSecurity 9 mins54. Why do many teams avoid CLI workspaces for production and staging, and what do they use instead?
mediumEnvironments 8 mins55. How do you make Terraform plan review in a pull request actually trustworthy?
hardCI/CD 9 mins56. How do you debug why Terraform is creating resources in an unexpected order?
hardDebugging 9 mins57. Terraform reports a cycle error. How do you find it and break it?
hardDebugging 9 mins58. What does terraform state rm actually do, and when does it create an orphan you regret?
mediumState Operations 8 mins59. How do you move Terraform state from one backend to another without losing anything?
mediumState Operations 8 mins60. A terraform plan takes twenty minutes. How do you diagnose and fix it?
hardPerformance 9 mins61. Terraform shows the same change on every plan even straight after an apply. How do you diagnose it?
hardDebugging 9 mins