Skip to main content
Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

Quickstart

Get started with Terraform in minutes with a simple example

Installation

Install Terraform on your system and verify the installation

Core Concepts

Understand Terraform’s key concepts and workflow

CLI Reference

Explore all available Terraform commands and options

What is Terraform?

Terraform codifies cloud APIs into declarative configuration files, allowing you to define infrastructure using a high-level configuration syntax. This enables you to version, reuse, and share infrastructure configurations just like application code. With Terraform, you write configuration files that describe the components needed to run your applications or services. Terraform then generates an execution plan describing what it will do to reach the desired state, and executes that plan to build the infrastructure.

Key Features

Infrastructure as Code

Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.
resource "aws_instance" "web" {
  ami           = "ami-a1b2c3d4"
  instance_type = "t2.micro"

  tags = {
    Name = "WebServer"
  }
}

Execution Plans

Terraform has a “planning” step where it generates an execution plan. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.
The terraform plan command shows you exactly what changes will be made before you apply them, helping you catch mistakes before they affect your infrastructure.

Resource Graph

Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

Change Automation

Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.

How Terraform Works

1

Write Configuration

Define your infrastructure in .tf files using HashiCorp Configuration Language (HCL)
2

Initialize

Run terraform init to download providers and initialize the working directory
3

Plan Changes

Run terraform plan to preview the changes Terraform will make
4

Apply Changes

Run terraform apply to create, update, or delete infrastructure to match your configuration
5

Manage State

Terraform tracks the current state of your infrastructure in a state file

Primary Commands

Terraform’s workflow revolves around five primary commands:
  • init: Initialize a Terraform working directory
  • validate: Validate the Terraform configuration files
  • plan: Generate and show an execution plan
  • apply: Build or change infrastructure
  • destroy: Destroy previously-created infrastructure

Getting Started

Ready to try Terraform? Head over to our Quickstart guide to create your first infrastructure with Terraform in just a few minutes.
Terraform is licensed under the Business Source License 1.1. Check the license terms for your use case.

Additional Resources

Terraform Website

Official Terraform documentation and resources

HashiCorp Learn

Interactive tutorials and learning paths

Community Forums

Get help and discuss with the Terraform community

Terraform Registry

Browse providers and modules from the community

Build docs developers (and LLMs) love