Quick Answer: This is the ultimate list of Terraform interview questions and answers for 2026 — covering core concepts, HCL, state management, modules, workspaces, providers, and advanced techniques (plus OpenTofu). Concise, interview-ready answers for DevOps and cloud-engineer roles.

Terraform Fundamentals
- What is Terraform?
An open-source Infrastructure as Code (IaC) tool by HashiCorp for provisioning infrastructure declaratively across clouds. - What is Infrastructure as Code?
Managing infrastructure through machine-readable definition files instead of manual processes. - What language does Terraform use?
HCL (HashiCorp Configuration Language), a declarative language; JSON is also supported. - What is declarative vs imperative IaC?
Declarative describes the desired end state (Terraform); imperative describes the steps to get there. - What is OpenTofu?
An open-source, community-driven fork of Terraform under the Linux Foundation — a near drop-in alternative after the license change. - What are the benefits of Terraform?
Multi-cloud support, versioned and reviewable infrastructure, repeatability, and a large provider ecosystem.
Core Workflow
- What are the core Terraform commands?
init,plan,apply, anddestroy. - What does terraform init do?
Initializes the working directory, downloads providers, and configures the backend. - What does terraform plan do?
Shows a preview of the changes Terraform will make without applying them. - What does terraform apply do?
Creates, updates, or deletes resources to match the configuration. - What is terraform validate?
Checks configuration syntax and internal consistency. - What is terraform fmt?
Formats configuration files to the canonical style. - What is terraform refresh?
Reconciles state with real-world resources (now part of plan/apply).
State Management
- What is the Terraform state file?
A file (terraform.tfstate) mapping your configuration to real resources. - Why is remote state important?
It enables team collaboration, locking, and a single source of truth, avoiding local-state conflicts. - What is a backend?
Where state is stored — e.g., S3, Azure Storage, GCS, or HCP Terraform. - What is state locking?
Preventing concurrent operations from corrupting state (e.g., via DynamoDB or native S3 locking). - How do you import existing resources?
Useterraform importor an import block to bring resources under management. - What is terraform state mv/rm?
Commands to move or remove resources within state without destroying them. - What is drift?
When real infrastructure differs from the state/config due to out-of-band changes. - How do you secure state?
Use an encrypted remote backend with restricted access; state can contain secrets.
Variables, Outputs & Data
- What are input variables?
Parameters that make configurations reusable and configurable. - What are output values?
Values exported from a configuration, useful for chaining modules or displaying results. - What is a data source?
A read-only query for existing infrastructure or external data. - What are locals?
Named expressions used to avoid repetition within a configuration. - What is variable precedence?
CLI flags > *.auto.tfvars / terraform.tfvars > environment variables > defaults. - What are sensitive variables?
Variables marked sensitive so their values are hidden in output/logs.
Modules & Reuse
- What is a module?
A reusable, self-contained package of Terraform configuration. - What is the root module?
The configuration in your working directory that may call child modules. - Where do you find reusable modules?
The public Terraform Registry or a private registry. - How do you version modules?
Pin module versions with the version argument or Git tags. - What is the benefit of modules?
DRY, consistent, and standardized infrastructure across teams/environments.
Meta-Arguments & Expressions
- What is count?
A meta-argument to create multiple instances of a resource by index. - What is for_each?
Creates multiple instances from a map or set, keyed by value. See our for_each guide. - count vs for_each — when to use which?
Use count for identical copies by number; for_each for distinct, named instances. - What is depends_on?
Explicitly declares dependencies Terraform can’t infer automatically. - What is a dynamic block?
Generates repeatable nested configuration blocks programmatically. - What is the lifecycle block?
Controls behavior like create_before_destroy, prevent_destroy, and ignore_changes. - What are provisioners and when should you avoid them?
They run scripts on resources; avoid them when possible in favor of native config or cloud-init.
Providers, Workspaces & Advanced
- What is a provider?
A plugin that lets Terraform manage a specific platform’s API (AWS, Azure, GCP, Kubernetes). - What is provider version pinning?
Constraining provider versions for reproducible builds. - What are workspaces?
Separate state instances within one configuration to manage multiple environments. - How do you manage multiple environments?
Workspaces, separate state files/directories, or tools like Terragrunt. - What is the .terraform.lock.hcl file?
The dependency lock file pinning provider versions and hashes. - What is policy as code in Terraform?
Enforcing guardrails using Sentinel or Open Policy Agent (OPA). - How do you run Terraform in CI/CD?
Run plan on PRs and apply on merge with approvals (GitOps for infrastructure). - Terraform vs Ansible?
Terraform provisions infrastructure declaratively; Ansible focuses on configuration management. See Terraform vs Ansible. - Terraform vs CloudFormation?
Terraform is multi-cloud with its own state; CloudFormation is AWS-native. - What is terraform taint (and its modern replacement)?
Marks a resource for recreation; replaced byterraform apply -replace. - How do you handle secrets in Terraform?
Use Vault, cloud secret managers, or environment variables — never commit secrets to code or state in plain text.
Frequently Asked Questions
Is Terraform still in demand in 2026?
Yes — Terraform (and OpenTofu) remains the leading multi-cloud IaC tool and a core skill in DevOps and cloud-engineer interviews.
What are the most important Terraform interview topics?
State management, modules, the core workflow, variables/outputs, count vs for_each, and running Terraform in CI/CD.
How do I practice Terraform?
Provision real resources in a free-tier cloud account, build reusable modules, and use a remote backend. See our Terraform tutorial.
Related: Terraform Tutorial · Terraform vs Ansible · DevOps Interview Questions
