All Tools
TE

Terraform

What is Terraform?


meta_title: What is Terraform? Infrastructure as Code Explained
meta_description: Terraform is HashiCorp’s infrastructure as code tool for provisioning cloud and on-prem resources through declarative config files.
slug: terraform
post_excerpt: Terraform is HashiCorp’s open infrastructure as code tool that lets you define, version, and provision cloud and on-prem resources through declarative configuration files.

tool_url: https://www.terraform.io
tool_logo: https://www.google.com/s2/favicons?domain=terraform.io&sz=128
tool_pricing: Freemium
tool_category: Cloud / IaC
tool_industry: Engineering & Product
tool_similar: Pulumi, Ansible, AWS CloudFormation, OpenTofu, AWS CDK
tool_glossary: Infrastructure as Code (IaC), HCL, state file, provider, declarative configuration, immutable infrastructure

tool_features: |
Declarative HCL configuration language that describes the desired end state of your infrastructure
Multi-cloud support through thousands of community and official providers in the Terraform Registry
State file that tracks real infrastructure and detects drift from your configuration
Plan and apply workflow that previews every change before it touches production
Reusable modules for packaging and sharing standardized infrastructure patterns
Resource graph that parallelizes non-dependent resource creation for faster provisioning

faq_1_q: Is Terraform free to use?
faq_1_a: Yes. The Terraform CLI is free to download and run on your own machine or CI pipeline. HashiCorp’s hosted service, HCP Terraform, adds a paid tier for remote state, team collaboration, and policy enforcement once you exceed its free tier of 500 managed resources. Most solo developers and small teams never need to pay anything.
faq_2_q: What is the difference between Terraform and Ansible?
faq_2_a: Terraform provisions infrastructure: it creates and destroys servers, networks, and databases based on a declarative description of the end state. Ansible configures what already exists: it installs software, changes settings, and runs tasks on servers that are already running. Many teams use both together, Terraform to stand up the infrastructure and Ansible to configure it afterward.
faq_3_q: What is a Terraform state file?
faq_3_a: The state file is a JSON record of every resource Terraform has created and the metadata attached to it, like IDs, IP addresses, and configuration values. Terraform compares this file against your configuration and real infrastructure every time you run a plan, which is how it knows exactly what to create, change, or destroy. Losing or corrupting it makes your infrastructure hard to manage safely.


Terraform is HashiCorp’s infrastructure as code tool: you describe the servers, networks, and databases you need in a text file, and Terraform creates them for you. Instead of clicking through a cloud console or running one-off scripts, you write a configuration once, and Terraform figures out the order of operations, tracks what already exists, and updates only what changed. It works across AWS, Azure, Google Cloud, Kubernetes, and thousands of other providers through a single, consistent workflow. For AI teams standing up GPU clusters, vector databases, and inference endpoints across multiple providers, Terraform turns infrastructure into version-controlled code instead of tribal knowledge locked in someone’s head.

How Terraform works

Terraform runs on a simple loop: you write what you want, Terraform shows you what it will do, and you approve before anything changes. It talks to cloud providers through their APIs, so it can create a virtual machine on AWS the same way it creates one on Azure, just through a different provider plugin.

Here is how the core workflow breaks down:

  • Write: You define resources in HCL (HashiCorp Configuration Language), a declarative syntax that describes the end state you want rather than the steps to get there.
  • Providers: Plugins that translate your HCL into API calls for a specific platform. The Terraform Registry hosts thousands of them, covering AWS, Kubernetes, Datadog, GitHub, and more.
  • Plan: Terraform compares your configuration against its state file and real infrastructure, then prints exactly what it will add, change, or destroy.
  • Apply: Once you approve the plan, Terraform executes the changes in the correct order, building a resource graph so independent resources deploy in parallel.
  • State: A file that records every resource Terraform manages and its current attributes. It is the source of truth Terraform uses to detect drift and plan future changes.

What you can build with Terraform

  • Multi-cloud AI infrastructure: Provision GPU instances on AWS, storage on GCP, and DNS on Cloudflare from one configuration, so your ML pipeline is not locked into a single vendor’s console.
  • Self-service developer platforms: Package a standardized module for spinning up a database, load balancer, and web server, so product teams request infrastructure without filing a ticket to the platform team.
  • Disaster recovery environments: Keep a full copy of your production configuration ready to apply in a second region, cutting recovery time from hours of manual clicking to a single terraform apply.
  • Kubernetes cluster provisioning: Stand up an EKS, GKE, or AKS cluster and configure its networking, node pools, and IAM roles in the same configuration that deploys your application workloads.
  • Ephemeral QA and staging environments: Spin up a full copy of production for a pull request, run tests against it, then tear it down automatically to avoid paying for idle infrastructure.
  • Policy-enforced infrastructure pipelines: Combine Terraform with Sentinel or Open Policy Agent so every proposed change is checked against cost limits and security rules before it reaches production.

Explore Similar AI Tools

Newsletter

The Twice-Monthly AI Briefing

Updates from the AI world — what shipped, what we’re using in production, and what’s worth your attention. Two emails a month, no spam.