Terraform interview question · Most asked

What is Terraform, and how does it work at a high level?

Summary

Terraform is an infrastructure-as-code tool: you declare resources in HCL configuration files, and Terraform builds a dependency graph, compares the configuration with the recorded state and the real infrastructure, produces a plan of creates, updates and deletes, and applies it through providers that call cloud and service APIs.

Longer Answer

Key pieces: providers (plugins for AWS, Azure, GCP, Kubernetes, GitHub, Datadog, and thousands more), resources (things Terraform manages), data sources (read-only lookups), variables, locals and outputs, modules (reusable groups of resources), and state (Terraform's record of what it manages and the real IDs).

Terraform is declarative: you describe the end state, not the steps. Because it calls APIs, the same workflow manages many platforms. Since HashiCorp moved Terraform to the Business Source License in 2023, the community fork OpenTofu (Linux Foundation, MPL licence) offers a compatible open-source alternative.

Key Points

  • Declarative HCL configuration.
  • Plan = diff of config, state and reality.
  • Providers call APIs.
  • OpenTofu is the open-source fork.

More most-asked Terraform questions

← All Terraform questions