πŸŽ“ A1Learner
πŸ”
0 of 50 lessons completed

What Is Terraform?

Terraform is a tool that creates and manages infrastructure from files written in code. It turns a written description into real servers, networks and storage.

A blueprint, not a set of clicks

A console asks you to click through screens. A Terraform file states the result you want.

# main.tf
resource "local_file" "hello" {
  filename = "hello.txt"
  content  = "Hello from Terraform."
}

One command builds it

The file alone does nothing. A command reads it and makes it real.

terraform apply

The same file, the same result

Run the file again on a fresh machine. Terraform builds the same file again.

terraform apply

Example

# main.tf
terraform {
  required_providers {
    local = {
      source  = "hashicorp/local"
      version = "2.9.1"
    }
  }
}

resource "local_file" "hello" {
  filename = "hello.txt"
  content  = "Hello from Terraform."
}

# Commands:
# terraform init
# terraform apply

Key points

  • Infrastructure means the parts a program runs on, such as servers, networks and storage.
  • Terraform reads a file and builds the infrastructure the file describes.
  • The same file builds the same infrastructure every time it runs.
  • A file can be saved, shared and reviewed like any other document.
  • Terraform keeps a record of what it built, so it can change or remove it later.

The file describes one small file on disk. Terraform reads the description and creates it. The output confirms one resource was added.

Note

Terraform builds infrastructure, it does not install programs inside a server.

Try it Yourself

Edit the code, then press Run.

Running is simulated Β· Rust Playground

Exercise

What does Terraform build infrastructure from?