Terraform (language)
By HashiCorp
The Terraform language is HashiCorp's declarative configuration language for describing infrastructure as code, built on top of the general-purpose HashiCorp Configuration Language (HCL). It lets users define cloud and on-premises…
Definition
The Terraform language is HashiCorp's declarative configuration language for describing infrastructure as code, built on top of the general-purpose HashiCorp Configuration Language (HCL). It lets users define cloud and on-premises resources — servers, networks, databases, and managed services — as structured configuration files that Terraform then reconciles against real, observed infrastructure state across one or many providers simultaneously and repeatably.
Overview
Provisioning cloud infrastructure by hand or through ad hoc scripts makes it difficult to know the current state of a system, replicate an environment reliably, or review infrastructure changes the way application code changes are reviewed carefully before merging into production. The Terraform language addresses this by letting engineers describe the desired end state of infrastructure declaratively, leaving Terraform's engine to figure out and execute the specific ordered steps needed to reach that target state safely. A Terraform configuration is written in HCL, a language purpose-built to be more structured than free-form scripting but more readable than raw JSON, expressing resources as typed blocks with named attributes, along with variables, outputs, and reusable modules that encapsulate common infrastructure patterns for reuse across teams and projects. When applied, Terraform compares the declared configuration against a stored state file representing what it last knew about real infrastructure, computes a difference, and generates an execution plan of create, update, or destroy operations needed to reconcile the two, which the user reviews carefully before allowing it to run. Among infrastructure and configuration languages, the Terraform language differs from imperative configuration-management tools' scripting approaches by being declarative rather than procedural, and it differs from cloud-specific declarative formats by being provider-agnostic, using plugins to target many clouds and services through one consistent syntax rather than being tied to a single vendor's native configuration format or dialect. In practice, teams write Terraform configurations to provision and manage cloud resources such as virtual machines, networking, storage, and managed services across providers, often organizing shared patterns into reusable modules and using variables and workspaces to manage multiple environments like staging and production from the same underlying shared codebase, avoiding drift between environments that were configured separately by hand. Configuration changes go through the same review and version control processes as application code, a practice generally described as infrastructure as code across the software industry today. The language's declarative model, combined with the state file it depends on, is also its main source of operational risk: state file drift, corruption, or team members applying changes outside of Terraform can desynchronize the declared configuration from real infrastructure, sometimes requiring careful manual reconciliation work to fix and validate afterward. Because the language spans so many providers through plugins, provider-specific behavior and API rate limits can also surface as friction that a single-cloud, vendor-native tool would not have to deal with in quite the same recurring way.
Key Features
- Declarative syntax built on HashiCorp Configuration Language (HCL)
- Generates an execution plan before applying infrastructure changes
- Tracks infrastructure state in a dedicated state file
- Supports reusable modules for shared infrastructure patterns
- Provider-agnostic through a plugin architecture across clouds
- Uses variables and workspaces to manage multiple environments
Use Cases
Alternatives
Frequently Asked Questions
From the Blog
Infrastructure as Code Explained: Terraform Basics
Clicking through cloud consoles doesn't scale. Infrastructure as Code (IaC) lets you define, version, and automate your cloud resources in code. This guide explains IaC concepts and walks you through Terraform — the most widely used IaC tool.
Read More Cloud & CybersecurityTerraform Basics: Infrastructure as Code on AWS
Terraform lets you define cloud infrastructure in code, version it in Git, and deploy it repeatably. This guide covers providers, resources, variables, outputs, state management, and real AWS examples — from a simple S3 bucket to a complete web server setup.
Read More Cloud & CybersecurityInfrastructure as Code With Terraform
Terraform lets you define cloud infrastructure in code, then create and change it safely and repeatably. Learn the core workflow and key concepts.
Read More Cloud & CybersecurityWhat Is Terraform and How It Works
Terraform is an infrastructure-as-code tool that lets you define cloud resources in declarative files and provision them safely with plan and apply commands.
Read More