Infrastructure as code

Terraform Interview Questions

State, modules, providers, planning and CI workflows for infrastructure changes that stay reviewable.

Quiz me
40 questions10 easy22 medium8 hard0/40 learned
01What is Terraform and how does it work?Easyterraform · hcl · declarative infrastructure02Why use infrastructure as code?Easyinfrastructure as code · automation · idempotency03How does Terraform compare with CloudFormation?Mediumcloudformation · aws · tooling04What are Terraform providers and how do you configure them?Easyproviders · plugins · version constraints05What is a Terraform resource?Easyresources · dependency graph · hcl06What are data sources and when should you use them?Mediumdata sources · lookups · planning07How do input variables work in Terraform?Easyvariables · inputs · validation08What are outputs used for?Easyoutputs · module interface · state09What are locals and when should you use them?Easylocals · expressions · dry10What is Terraform state and why is it needed?Mediumstate · mapping · operations11Why use remote state and how do you configure it?Mediumremote state · backend · s312How does state locking work and what do you do about stale locks?Mediumlocking · concurrency · dynamodb13When should you use Terraform workspaces?Mediumworkspaces · isolation · environments14What is a Terraform module and how do you use one?Mediummodules · reuse · registry15How do you compose multiple modules without creating a tangled architecture?Hardmodule composition · architecture · interfaces16What does terraform init do?Easyterraform init · providers · backend17How do you safely review and apply a Terraform plan?Mediumplan · apply · review18How do you destroy infrastructure safely?Mediumdestroy · safety · lifecycle19How do you detect and handle infrastructure drift?Mediumdrift · refresh · reconciliation20How do lifecycle rules change create, update and destroy behaviour?Hardlifecycle · replacements · safety21When should you use depends_on?Mediumdependency ordering · dependency graph · explicit dependencies22When should you use count versus for_each?Mediumcount · for each · instances23How do dynamic blocks work and when should you avoid them?Harddynamic blocks · nested blocks · iteration24How do conditionals work in Terraform?Mediumconditionals · ternary · expressions25Which Terraform functions are most useful in practice?Mediumfunctions · expressions · transformation26Why are provisioners considered a last resort?Mediumprovisioners · bootstrap · anti-patterns27What does HCP Terraform provide?Easyhcp terraform · remote runs · state28How do you design a safe Terraform CI/CD pipeline?Hardci cd · automation · oidc29How should you handle secrets in Terraform?Mediumsecrets · sensitive data · state30How do you secure Terraform state?Hardstate security · encryption · iam31How do you structure Terraform across multiple environments?Mediumenvironments · isolation · layout32How do you design a consistent tagging strategy?Easytagging · cost allocation · governance33Why pin Terraform and provider versions?Mediumversion pinning · lock file · upgrades34How do you bring existing infrastructure under Terraform management?Mediumimport · adoption · brownfield35How do moved blocks prevent unnecessary destruction during refactors?Hardrefactoring · moved blocks · state36How do you test Terraform code?Hardtesting · terratest · terraform test37How do you enforce policy as code for Terraform?Mediumpolicy as code · opa · sentinel38What are the most common Terraform mistakes in production?Mediummistakes · review · operations39How does Terraform fit into disaster recovery?Harddisaster recovery · state recovery · rto40What Terraform practices would you standardise across a team?Mediumbest practices · workflow · reliability

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Terraform mock interview and get scored feedback on depth, clarity and confidence.