{"id":13505839,"url":"https://github.com/pcasteran/terraform-graph-beautifier","last_synced_at":"2025-10-21T04:55:11.799Z","repository":{"id":39589196,"uuid":"258291769","full_name":"pcasteran/terraform-graph-beautifier","owner":"pcasteran","description":"Terraform graph beautifier","archived":false,"fork":false,"pushed_at":"2024-04-29T00:45:36.000Z","size":595,"stargazers_count":388,"open_issues_count":10,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-15T20:55:12.873Z","etag":null,"topics":["cytoscapejs","golang","graphviz","graphviz-dot","terraform","terraform-graph"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pcasteran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-23T18:12:15.000Z","updated_at":"2025-10-05T09:05:18.000Z","dependencies_parsed_at":"2023-02-19T03:15:53.089Z","dependency_job_id":"4fdf6cb0-bf4f-47a8-897f-3dd51f6811f6","html_url":"https://github.com/pcasteran/terraform-graph-beautifier","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/pcasteran/terraform-graph-beautifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcasteran%2Fterraform-graph-beautifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcasteran%2Fterraform-graph-beautifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcasteran%2Fterraform-graph-beautifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcasteran%2Fterraform-graph-beautifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pcasteran","download_url":"https://codeload.github.com/pcasteran/terraform-graph-beautifier/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcasteran%2Fterraform-graph-beautifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280207203,"owners_count":26290616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cytoscapejs","golang","graphviz","graphviz-dot","terraform","terraform-graph"],"created_at":"2024-08-01T00:01:15.131Z","updated_at":"2025-10-21T04:55:11.764Z","avatar_url":"https://github.com/pcasteran.png","language":"Go","funding_links":[],"categories":["Go","Tools","golang"],"sub_categories":["Community providers"],"readme":"# Terraform graph beautifier\n\nCommand line tool allowing to convert the barely usable output of the `terraform graph` command to something more\nmeaningful and explanatory.\n\n| `terraform graph` raw output | Processed output |\n| :-: | :-: |\n| ![?](doc/config1_raw.png) | ![?](doc/config1_cyto_embedded.png) |\n\n## Installation\n\nYou can download the binary corresponding to the required platform from\nthe [release](https://github.com/pcasteran/terraform-graph-beautifier/releases) page.\n\nYou can also build the binary from the sources:\n\n```bash\ngo install github.com/pcasteran/terraform-graph-beautifier\n```\n\nFinally, you can also use\nthe [Docker images](https://github.com/pcasteran/terraform-graph-beautifier/pkgs/container/terraform-graph-beautifier)\navailable for the Linux and Darwin operating systems:\n\n```bash\n# Linux\ndocker pull ghcr.io/pcasteran/terraform-graph-beautifier:latest-linux\n\n# Darwin\ndocker pull ghcr.io/pcasteran/terraform-graph-beautifier:latest-darwin\n```\n\n## Basic usage\n\n```bash\ncd samples/config1/\nterraform init\n\n# Using the binary.\nterraform graph | terraform-graph-beautifier \\\n    --output-type=cyto-html \\\n    \u003e config1.html\n\n# Using the Docker image.\nterraform graph | docker run --rm -i \\\n    --name terraform-graph-beautifier \\\n    ghcr.io/pcasteran/terraform-graph-beautifier:latest-linux \\\n    --output-type=cyto-html \\\n    \u003e config1.html\n```\n\n## Input and outputs\n\nThe command performs the following:\n\n1. Parsing of the Graphviz [Dot](https://www.graphviz.org/doc/info/lang.html) script generated by `terraform graph` from\n   the standard input or the specified file (`--input` parameter).\n1. Extraction of the graph containing the Terraform configuration elements and their dependencies.\n1. Generation of the result to the standard output or file (`--output` parameter). The following output\n   types (`--output-type` parameter) are supported:\n    - **cyto-html** (default): an HTML page using [Cytoscape.js](https://js.cytoscape.org/) to render the graph (\n      see [example](doc/config1.html));\n    - **cyto-json**: a JSON document of the graph in the\n      Cytoscape.js [format](https://js.cytoscape.org/#notation/elements-json) (see [example](doc/config1.json));\n    - **graphviz**: a cleaned and prettier Dot script that can be piped to a\n      Graphviz [rendering command](https://linux.die.net/man/1/dot) (see [example](doc/config1.gv)).\n\n### Input graph loading and processing\n\nThe loading of the input graph involves the following steps:\n\n1. **Cleaning the Dot script**\n    1. Renaming the nodes using a more consistent\n       pattern: `[root] rsc_type.rsc_name` =\u003e `module.root.rsc_type.rsc_name`.\n    1. Using the `'` character instead of `\"` fot the maps keys: `buckets[\"artefacts\"]` =\u003e `buckets['artefacts']`.\n    1. Removing the nodes and edges generated by Terraform but not corresponding to configuration elements (aka TF\n       junk). This can be deactivated via the `--keep-tf-junk` parameter.\n1. **Filtering**\n    - Using user-provided pattern(s) to exclude some elements (resource, var, module, provider, ...) from the output.\n    - These patterns are [Go regexp](https://golang.org/pkg/regexp/) and are matched line by line against the output of\n      the **cleaning** step, so use the `\"root.rsc_type.rsc_name\"` naming convention.\n    - These patterns are provided using the `--exclude` parameter, you can repeat it multiple times.\n\n### Output configuration\n\n#### Modules embedding\n\nAn important option is to choose whether to embed a submodule in its parent module or not. The `--embed-modules`\nparameter allows to control this behavior:\n\n- if **true** (default), the modules subgraphs will be embedded inside their parent;\n- if **false**, all the subgraphs are drawn at the same level and an edge is drawn from a parent to its children.\n\nAs a rule of thumb, `--embed-modules=true` works well for small to medium size graphs but for larger ones it can produce\na very dense and compact result with a lot of overlapping nodes and intersecting edges.\n\n| Output type | `--embed-modules=true` | `--embed-modules=false` |\n| :-: | :-: | :-: |\n| **cyto-html** | ![?](doc/config1_cyto_embedded.png) | ![?](doc/config1_cyto_no-embedded.png) |\n| **graphviz** | ![?](doc/config1_graphviz_embedded.png) | ![?](doc/config1_graphviz_no-embedded.png) |\n\n#### HTML output templating\n\nThe command uses Go [templates](https://golang.org/pkg/text/template/) to create the HTML output.\nThe following annotations will be replaced during the output generation:\n\n- **{{.PageTitle}}**: will be replaced by the graph name (see `--graph-name` parameter).\n- **{{.GraphElementsJSON}}**: will be replaced by the graph elements JSON object.\n\nA basic template, with sensible default values for the graph rendering (style and layout), is provided and is embedded\nin the binary.\n\nIf you want to customize the output, you can provide your own template and specify to use it with\nthe `--cyto-html-template` parameter.\nIt is good practice to check in your custom templates alongside your Terraform configuration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcasteran%2Fterraform-graph-beautifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpcasteran%2Fterraform-graph-beautifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcasteran%2Fterraform-graph-beautifier/lists"}