All posts

Understand a Terraform Config at a Glance

July 31, 2026 · DevTools

terraform
iac
hcl
devops
infrastructure

A Terraform project starts life as a tidy main.tf and grows, over months, into a folder of files where a single resource pull from a data source, shaped by a variable, and exposed through an output, also calls a module that itself declares ten more resources. Reading that configuration by scrolling line by line works for small configs and fails for real ones. A better approach is to read the block structure first — the skeleton that tells you what's there and how it connects — before you dive into any individual argument.

The five blocks you'll meet

HCL configurations combine blocks and attributes, and most Terraform configs use the same handful of block types:

  • resource — something you create (an EC2 instance, an S3 bucket). Labeled <type>.<name>, e.g. aws_instance.web.
  • data — something you read but don't manage (the latest AMI, an existing subnet).
  • variable — an input, with a type and often a default.
  • output — a value you expose after apply.
  • module — a reusable bundle of resources from another path or registry.
  • (provider, terraform, and locals round out the cast.)

Once you can see how many of each you have, you understand the shape of the configuration — and that's usually enough to know where to look.

Trace the dependencies

The real insight is how blocks reference each other. An output that reads aws_instance.web.id depends on that resource; a resource whose ami is data.aws_ami.latest.id depends on that data source; a count = var.instance_count ties the resource to a variable. These dotted references are the wiring diagram of your infrastructure.

output "web_id" {
  value = aws_instance.web.id
}
resource "aws_instance" "web" {
  ami           = data.aws_ami.latest.id
  instance_type = "t3.micro"
  count         = var.instance_count
}

Visualize instead of scroll

The Terraform HCL Visualizer does the reading for you. Paste a .tf file and it counts blocks by type (so you see the shape instantly), lists each block with its labels and attributes (including nested blocks), and infers the dotted references between them — output.web_id → aws_instance.web.id, aws_instance.web → data.aws_ami.latest, and so on. It's a pragmatic parser focused on structure, not a full HCL implementation, which makes it fast and forgiving for review.

It's especially useful when you inherit a config someone else wrote: the block inventory tells you what's in the room, and the inferred references tell you how it's wired, before you've read a single resource body.

When to go deeper

Structure-first reading is for understanding and review. For authoring and change safety you still want terraform plan against the real state, and for the definitive dependency graph you want terraform graph. But for the first thirty seconds of "what is this config" — what blocks exist, what depends on what — a structural pass is the fastest path to a mental model, and it runs entirely in your browser on the text you paste.

Tools mentioned in this post