DevTools Logo

Terraform DAG Diagrammer

Terraform DAG Diagrammer

Turn Terraform HCL into a deterministic Mermaid dependency graph in your browser

Terraform HCL

About

Paste Terraform HCL to inspect resource and data blocks, variable and block references, Mermaid flowchart output, and dependency cycles. Parsing runs entirely in your browser.

Examples

Reference linking with string masking

Input
buildTerraformDag('resource "aws_vpc" "main" { cidr_block = var.cidr }\nresource "aws_subnet" "app" { vpc_id = aws_vpc.main.id note = "aws_vpc.fake.id" }')
Output
edges: [aws_subnet.app → aws_vpc.main], references of main include var.cidr

Real HCL references link blocks while the quoted fake address stays masked, and var.cidr is recorded without becoming a node.

Two-resource cycle

Input
buildTerraformDag('resource "b" "two" { depends_on = [a.one] }\nresource "a" "one" { depends_on = [b.two] }')
Output
cycles: [["a.one", "b.two", "a.one"]], mermaid nodes tf_a_one, tf_b_two

Mutual references produce one cycle path, both addresses in cyclicResources, and deterministic Mermaid node IDs.

About this tool

Terraform DAG Diagrammer parses resource and data blocks with buildTerraformDag(source) (also exported as parseTerraformHcl and analyzeTerraformDag): headers match resource/data "type" "name" {, brace depth is tracked on comment- and string-masked HCL, and blocks sort deterministically by address with data blocks prefixed data..

References resolve only against known block addresses: bare type.name.attr links become edges, while var., local., and module. hits are kept in each block's references list but never become nodes or edges. Comments and quoted strings are masked before scanning, so a resource-looking header inside a string literal is ignored.

Cycles surface explicitly via depth-first search: cycles holds each loop path (e.g. a.one → b.two → a.one) and cyclicResources lists the sorted participants, and the Mermaid output always starts with flowchart TD followed by sorted node lines then sorted edges.

How to use this tool

  1. Paste Terraform HCL

    Drop resource and data blocks into the input — variables, locals, and outputs without blocks are skipped automatically.

  2. Read nodes and edges

    Check the sorted block addresses and from → to edges to confirm each dependency points at a defined block.

  3. Inspect cycles and Mermaid

    Review cycles and cyclicResources for loops, then copy the flowchart TD diagram into Mermaid for visualization.

Use cases

Visualizing module dependencies

Turn a pile of resource blocks into a sorted edge list and Mermaid flowchart for review.

Hunting dependency cycles

Surface mutual depends_on or interpolation loops via cycles before running terraform plan.

Auditing orphan references

Compare each block's references against edges to spot var/local inputs versus true block links.

Common mistakes

Mistake:Expecting var. and local. entries to appear as graph nodes.

Fix:They are kept in references only — edges and Mermaid nodes are built solely from known resource/data addresses.

Mistake:Assuming a quoted resource name creates a block.

Fix:Strings and comments are masked before header scanning, so headers inside quotes are never parsed as blocks.

Mistake:Reading source order as graph order.

Fix:Blocks, references, edges, and Mermaid lines all sort with localeCompare — input order never affects the output.

Frequently asked questions

What does this tool do?

It parses resource and data blocks with buildTerraformDag (aliases parseTerraformHcl, analyzeTerraformDag), links type.name references into sorted edges, detects cycles, and emits a flowchart TD Mermaid diagram with deterministic node IDs.

Do var, local, and module references become nodes?

No. They are recorded in each block's references list but never become nodes or edges — only references matching a known resource or data address produce edges.

Is my Terraform code uploaded or stored?

No. Masking, block parsing, cycle detection, and Mermaid rendering are 100% client-side — your HCL never leaves your browser.

Why does a resource name inside a string not create a block or edge?

Comments and quoted strings are masked before scanning, so headers or addresses inside string literals are ignored and only real HCL references link blocks.

References & standards

.env Secret Safety Linter

Validate .env syntax and spot likely leaked credentials or placeholder secrets.

.htaccess Generator

Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth

2D Fluid Dynamics & Particle Physics Sandbox

A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.

AI Function Calling Schema Generator

Generate function calling JSON schemas from TypeScript interfaces

Algorithm Arena & Data Structure Visualizer

Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.

Ansible Playbook Generator

Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML