Terraform DAG Diagrammer
Turn Terraform HCL into a Mermaid dependency graph in your browser
Terraform HCL
35 lines · 587 charsMermaid dependency graph
8 blocks · 9 edgesflowchart TD
tf_aws_instance_web[aws_instance.web]
tf_aws_internet_gateway_gw[aws_internet_gateway.gw]
tf_aws_subnet_app[aws_subnet.app]
tf_aws_vpc_main[aws_vpc.main]
tf_data_aws_ami_ubuntu[aws_ami.ubuntu]
tf_local_name[local.name]
tf_output_web_id[output.web_id]
tf_var_env[var.env]
tf_aws_instance_web -.-> tf_aws_internet_gateway_gw
tf_aws_instance_web --> tf_aws_subnet_app
tf_aws_instance_web --> tf_aws_vpc_main
tf_aws_instance_web --> tf_data_aws_ami_ubuntu
tf_aws_internet_gateway_gw --> tf_aws_vpc_main
tf_aws_subnet_app --> tf_aws_vpc_main
tf_aws_vpc_main --> tf_local_name
tf_local_name --> tf_var_env
tf_output_web_id --> tf_aws_instance_webExamples
Reference linking with string masking
buildTerraformDag('resource "aws_vpc" "main" { cidr_block = var.cidr }\nresource "aws_subnet" "app" { vpc_id = aws_vpc.main.id note = "aws_vpc.fake.id" }')edges: [aws_subnet.app → aws_vpc.main], references of main include var.cidrReal HCL references link blocks while the quoted fake address stays masked, and var.cidr is recorded without becoming a node.
Two-resource cycle
buildTerraformDag('resource "b" "two" { depends_on = [a.one] }\nresource "a" "one" { depends_on = [b.two] }')cycles: [["a.one", "b.two", "a.one"]], mermaid nodes tf_a_one, tf_b_twoMutual 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
Paste Terraform HCL
Drop resource and data blocks into the input — variables, locals, and outputs without blocks are skipped automatically.
Read nodes and edges
Check the sorted block addresses and from → to edges to confirm each dependency points at a defined block.
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.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.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.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.