Convert Terraform into an architecture diagram.
Terraform records dependencies explicitly through references, so the edges are read rather than inferred. It is one of the most reliable sources there is.
Why Terraform converts well
When one resource interpolates another's attribute, that is a dependency the language itself has recorded. Most sources require inferring relationships; here they are declared. The result is a diagram whose edges are as accurate as the configuration, which is a much stronger guarantee than anything derived from reading application code.
Configuration or state
Reading .tf files gives you what should exist. Pointing it at a state file or a saved plan gives you what does. Those differ more often than anyone likes, usually because something was changed by hand, and knowing which question you are asking is worth being deliberate about.
Modules are followed
A diagram of a root module that shows module blocks as opaque boxes is not much use. Module sources are followed so the components inside them appear, which is what makes the output a diagram of the infrastructure rather than of the file layout.
Fidelity
| Comes through | Does not | |
|---|---|---|
| Resources | Every declared resource | Anything created outside Terraform |
| Dependencies | References and depends_on | Runtime coupling not expressed in config |
| Modules | Followed to source and expanded | Remote modules not fetched locally |
| count and for_each | One logical component | Not expanded per instance |
| Variables | Resolved where defaults exist | Values supplied at apply time |
| Providers | Mapped to the external tier | Provider-side behaviour |
The command
Questions
Related
- Convert Code to a DiagramThe general case: point it at code and get a diagram of what is there rather than what you remember building.
- Convert a Diagram into CodeThe direction almost nothing else does: the diagram stops being documentation and becomes the instruction.
- Convert Mermaid to ExcalidrawUseful when a Mermaid diagram has outgrown what Mermaid's layout can render legibly.
- Convert SQL to an ER DiagramForeign keys already encode the relationships and their cardinality. The diagram renders what the schema is enforcing anyway.