generate_diagram
Render an architecture diagram from Terraform code to PNG, SVG, PDF, or draw.io, using actual plan data for AWS, Azure, and GCP deployments.
Instructions
Render an architecture diagram from Terraform code to a file.
Uses the official AWS, Azure and GCP icon sets. Because the diagram is
derived from terraform plan, it reflects what the code actually
deploys rather than an approximation. Runs terraform init and
terraform plan (cloud credentials needed) unless planfile and
graphfile are given, so a first call can take minutes.
Returns {"path", "format", "provider", "title", "files"}, plus a preview image. "files" holds the PNG, SVG, draw.io file and the graph as .tvg.json, which can be edited and rendered again with render_graph; "path" is the file in the requested format.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| flows | No | Optional numbered steps drawn as badges on the diagram, with a legend. Keyed by flow name: {"order_request": {"description": "A customer places an order", "steps": [{"resource": "tv_aws_users.users", "detail": "Customer opens the app"}, {"resource": "aws_alb.api~1 -> aws_ecs_fargate.app~1", "detail": "Request routed to a task"}]}}. A step names a node, or an arrow as "<node> -> <node>" in either direction; use the numbered copy (aws_alb.api~1), not the bare name. Steps are numbered across flows. Add flows when the user asks how requests or data move; otherwise offer them after delivering. Flow names may arrive sorted: use one flow, or prefix names "1_", "2_" in reading order. Name nodes as they appear in the .tvg.json graph of an earlier render, which can differ from the Terraform addresses. | |
| title | No | Heading shown above the diagram, e.g. "Order Platform - Production". Defaults to "Cloud Architecture Diagram". Overrides a title in the annotation file. | |
| format | No | "png", "svg", "pdf", "dot" or "drawio" (editable in draw.io and Lucidchart). The full set is always saved; use "svg" to embed in Markdown. | png |
| source | Yes | Terraform directory, Git URL, or tfdata.json replay file. Add //folder to a Git URL for a folder inside the repository, e.g. "https://github.com/org/repo//examples". A repository whose root is a reusable module plans no resources: draw a folder that uses it instead (examples/, an environment). | |
| outfile | No | Output file name without extension, e.g. "three_tier". Files always go to the server's output folder; from a path, only the last part is used. The cloud provider is appended: "architecture" becomes "architecture-aws". | architecture |
| preview | No | Include a preview image of the diagram in the result. | |
| upgrade | No | Run `terraform init -upgrade` to refresh modules. | |
| varfile | No | Paths to .tfvars files. | |
| annotate | No | Path to a terravision.yml annotation file. | |
| fontsize | No | Label font size in points. | |
| iconsize | No | Icon size in pixels. | |
| planfile | No | Path to an existing plan JSON (terraform show -json). With graphfile, no Terraform run and no cloud credentials are needed. | |
| graphfile | No | Path to an existing `terraform graph` DOT file. | |
| workspace | No | Terraform workspace to select. | default |
| simplified | No | Show only services, omitting networking containers. | |
| edge_labels | No | Optional text on arrows the graph already has, to say what each connection does: {"aws_ecs_fargate.app~1 -> aws_rds_sqlserver.db": "Reads orders"}. Either direction names the arrow; a label never adds one. Keep labels to a few words; offer them with the flows rather than adding them unasked. Name nodes as in the .tvg.json graph of an earlier render. | |
| use_tf_names | No | Label nodes with full Terraform resource names. | |
| use_resource_names | No | Label nodes with the deployed resource names from the plan. |