Terraform is an open-source infrastructure as code (IaC) tool created by HashiCorp. Terraform enables developers to provision, update and destroy on-premises and cloud infrastructure components—such as virtual machines and Kubernetes clusters—by writing human-readable configuration files.
HashiCorp Terraform uses a declarative language rather than a procedural language. Users describe the desired end state for infrastructure resources, and Terraform handles the rest. Terraform automatically creates an execution plan, identifies dependencies between resources and provisions components in the correct order. For example, if a virtual machine (VM) depends on a virtual private cloud (VPC), Terraform ensures the VPC is created before provisioning the VM.
In contrast, with a procedural language, developers must write step-by-step instructions to provision infrastructure.
Terraform configuration files can be versioned, reused and shared. Terraform manages low-level components, such as compute and storage resources, and high-level components, such as Domain Name System (DNS) entries and software as a service (SaaS) features.
In February 2025, IBM acquired HashiCorp and its offerings, including Terraform.
Terraform creates and manages resources on cloud platforms and other services through application programming interfaces (APIs). Terraform works with virtually any platform or service with an accessible API, including Amazon Web Services (AWS), Microsoft Azure, Google Cloud, GitHub, IBM Cloud and Docker.
The core Terraform workflow consists of three stages:
A developer writes a human-readable configuration file to define the resource configurations for their desired infrastructure. The file is declarative, meaning the developer describes the infrastructure they want but not how to provision it.
For example, if a developer wants to provision infrastructure for deploying a cloud-hosted app, they might specify that they need virtual machines in a virtual private cloud, with associated security groups and a load balancer.
A single configuration file can manage resources located across multiple cloud providers and services.
Terraform analyzes both the written configuration provided by the developer and the current state of the organization’s infrastructure. It then creates an execution plan describing how it will reach the desired end state from the current state.
The plan itself takes the form of a list of infrastructure that Terraform will create, update or destroy to bring the real world in line with the developer’s described configurations.
Consider the previous example of a developer deploying an application on virtual machines in a virtual private cloud. Terraform’s plan might include actions such as:
Developers can review and modify the plan before Terraform executes it.
When the plan is approved, Terraform performs the proposed operations in the correct order, respecting any resource dependencies. That is, if resource A depends on resource B, Terraform ensures that resource B is created before resource A.
For example, if a developer updates the properties of a VPC and changes the number of virtual machines in that VPC, Terraform recreates the VPC with updated properties before scaling the virtual machines.
The primary components of Terraform include:
Configuration files are how developers define their desired resources for on-premises and cloud environments. These files tell Terraform what providers to use, what infrastructure to create and what data to fetch. Developers can modify, reuse and share configuration files.
Developers can write configuration files in JSON or in HashiCorp Configuration Language (HCL). HCL uses a declarative syntax: Developers describe their desired infrastructure rather than specifying how to provision it. HCL resembles JSON’s key-value pairs, but it is optimized for human readability.
Modules are reusable containers for multiple resources that are commonly used together. For example, a module might contain virtual machines, databases, network configurations and security settings all in one package. Modules are stored as collections of configuration files.
Terraform modules allow developers to create complex infrastructure without starting from scratch every time. Instead, they can use modules that already describe the infrastructure arrangements they need.
A Terraform state file is a representation of the current state of infrastructure, including components, configurations and relationships between resources.
When Terraform creates a plan, it starts by comparing the configuration file to the state file. This enables Terraform to determine the changes it needs to make to bring current infrastructure in line with the desired configuration.
Terraform providers are plug-ins that let Terraform interact with APIs for external services and platforms. Providers enable Terraform to manage resources in infrastructure as a service (IaaS), platform as a service (PaaS) and software as a service (SaaS) environments. Each provider contains all the code Terraform needs to connect to a service, authenticate and provision resources.
While developers can write their own providers, they can also use preexisting providers written by HashiCorp and other Terraform users. There are prebuilt providers for most major private and public cloud services, as well as for databases, networking solutions and other common tools.
The Terraform Registry is a repository for providers, modules, policy rules and solutions.
Anyone can publish and consume the resources on the public Terraform Registry. Organizations can also create private registries to share their own modules and resources internally.
The Terraform CLI is the command-line interface (CLI) tool for managing infrastructure with Terraform. Developers use it to execute commands, generate execution plans, apply changes and interact with key Terraform components such as configuration files, state files, providers and modules.
Organizations use Terraform to provision and manage infrastructure throughout its lifecycle. Common use cases include:
Multicloud environments can be complex because each cloud provider has its own interfaces, tools and workflows. Furthermore, key resources can be distributed across multiple data centers.
Organizations can use Terraform to simplify the management and orchestration of large-scale multicloud infrastructures. Specifically, Terraform enables organizations to use the same configuration language to provision and manage resources across multiple service providers in a single workflow.
Terraform can deploy and manage infrastructure for multitier applications, enabling organizations to manage resources for each tier in a unified workflow while respecting dependencies.
For example, a multitier application might consist of a pool of web servers, a database tier, an API layer, caching servers and a routing tier. Terraform would provision the database tier before provisioning the web servers that depend on it.
At large organizations, centralized IT operations teams typically receive many repetitive infrastructure requests.
Organizations can use Terraform to build a self-serve infrastructure model that empowers product teams to manage their own infrastructure independently. For example, by using prebuilt modules, teams can directly deploy standardized and approved components.
Organizations can also integrate Terraform with ticketing systems and continuous integration/continuous delivery (CI/CD) DevOps pipelines to help automate new infrastructure provisioning requests. For example, when a user submits an infrastructure request to the ticketing system, Terraform can start a workflow to automatically update resources accordingly.
Terraform can help organizations enforce security and compliance policies on the types of resources teams can provision and use.
For example, organizations can use Terraform modules to codify standards for deploying and managing resources across the organization. When other teams use these approved modules, they can be sure they are deploying resources in compliance with organizational practices.
Organizations can store Terraform configuration files in a version control system (VCS), which enables DevOps teams to collaborate on code, review definitions, track infrastructure changes and roll back to previous infrastructure versions if necessary.
Kubernetes and Terraform are common components of cloud environments, and they both help automate infrastructure-related tasks. However, the core difference between the two is that Kubernetes focuses on containerized workloads, while Terraform manages all kinds of infrastructure components, including Kubernetes clusters themselves.
Kubernetes is an open-source container orchestration platform for scheduling and automating the deployment, management and scaling of containerized applications. Terraform is an infrastructure as code tool that automates the provisioning and managing of infrastructure.
While these are distinct tools with different functions, they often work together in cloud environments. For example, Terraform can automate the provisioning of Kubernetes clusters on cloud platforms, while Kubernetes manages the deployment of applications within these clusters.
Terraform and Ansible are both infrastructure as code tools that help automate core infrastructure tasks. However, they use different languages and often serve different purposes. Terraform is used to provision infrastructure resources, while Ansible is often used for managing resource configurations.
Terraform uses a purely declarative language, while Ansible combines both declarative and procedural languages. In procedural configuration, a developer specifies the steps for configuring resources in the desired state. Procedural configuration is more labor intensive, but it can also provide more control.
Ansible playbooks, written in YAML, allow for fine-grained control over tasks such as installing software and updating system settings. Ansible also has a variety of prebuilt modules for common configuration management tasks, including package management and operating system updates. And Ansible can apply changes to resources idempotently—meaning that, after an operation is applied the first time, further applications of the same operation do not change the resource.
Taken together, these characteristics help explain why Ansible is a common choice for configuration management.
While Terraform can provision infrastructure resources, it cannot manage software inside of resources as effectively as Ansible. For example, Terraform can define a new virtual machine, including properties such as instance type and disk size, but it cannot update the operating system on the virtual machine.
However, Terraform can work hand-in-hand with configuration management tools such as Ansible to simplify and streamline infrastructure configuration. For example, an organization might use Terraform to provision virtual machines and Ansible to configure the software on those machines.
Discover how IBM® Turbonomic helps manage cloud spend and application performance, with a potential 247% ROI over 3 years.
Learn best practices and considerations for selecting a cloud optimization solution from PeerSpot members who use Turbonomic.
Learn how users of IBM Turbonomic achieved sustainable IT and reduced their environmental footprint while assuring application performance.
Automatically scale your existing IT infrastructure for higher performance at lower costs.
Discover how AI for IT operations delivers the insights you need to help drive exceptional business performance.
Move beyond simple task automations to handle high-profile, customer-facing and revenue-producing processes with built-in adoption and scale.
IBM web domains
ibm.com, ibm.org, ibm-zcouncil.com, insights-on-business.com, jazz.net, mobilebusinessinsights.com, promontory.com, proveit.com, ptech.org, s81c.com, securityintelligence.com, skillsbuild.org, softlayer.com, storagecommunity.org, think-exchange.com, thoughtsoncloud.com, alphaevents.webcasts.com, ibm-cloud.github.io, ibmbigdatahub.com, bluemix.net, mybluemix.net, ibm.net, ibmcloud.com, galasa.dev, blueworkslive.com, swiss-quantum.ch, blueworkslive.com, cloudant.com, ibm.ie, ibm.fr, ibm.com.br, ibm.co, ibm.ca, community.watsonanalytics.com, datapower.com, skills.yourlearning.ibm.com, bluewolf.com, carbondesignsystem.com