Use the inframap CLI
masterinframap CLI reads Terraform State (TFState) or HCL files to generate a graphical view consisting of nodes and edges. It can accept input via a file path provided as an argument or via STDIN.repository·master·Indexed 24 days ago
https://github.com/cycloidio/inframapA tool that reads Terraform State or HCL files to generate graphical representations of infrastructure using nodes and edges. It includes a generate command for creating graphs with customizable printer and rendering flags, and a prune command for pruning Terraform State files.
inframap CLI reads Terraform State (TFState) or HCL files to generate a graphical view consisting of nodes and edges. It can accept input via a file path provided as an argument or via STDIN.The prune command supports the following flags:
--canonicals: A boolean flag (default: false). If set, the prune command will also assign random names to the resources (e.g., aws_lb.front => aws_lb.123).The generate command supports several flags to control how the graph is constructed and rendered:
| Flag | Type | Default | Description |
|---|---|---|---|
--printer | string | dot | The type of printer to use for the output. Supported types are listed by running inframap generate --help. |
--raw | boolean | false | If set, the tool will not use provider-specific logic and will only display connections between elements. This is used by default if no provider is recognized. |
--clean | boolean | true | If set, the generated graph will not include any nodes that do not have a connection/edge. |
--connections | boolean | true | If set, applies provider logic to remove resources that are not nodes. |
--show-icons | boolean | true | Toggles the display of icons on the printed graph. |
--external-nodes | boolean | true | Toggles the addition of external nodes like im_out (used to show ingress connections). |
--description-file | string | "" | Specifies a file (which will be created or overwritten) to output the description of the returned graph, including attributes of all visible nodes. |
--alternative-node-names | boolean | false | If set, the tool attempts to read node names from tags, labels, and other sources instead of using canonical names. |
By default, inframap attempts to automatically detect the input type by trying to parse the content as JSON (TFState). If JSON parsing fails, it falls back to HCL. You can override this behavior using the following persistent flags:
--hcl: Forces the use of the HCL parser.--tfstate: Forces the use of the TFState parser.version command to print the current build version of inframap. This is useful for verifying the installed version or ensuring compatibility with specific infrastructure providers.The generate command creates an infrastructure graph from either a Terraform State file (tfstate) or HCL files. You can provide a file path as an argument or pipe the content directly into the command via stdin.
Usage Patterns:
inframap generate [FILE]cat [FILE] | inframap generateinframap generate state.tfstate
cat state.tfstate | inframap generateThe prune command is used to prune a Terraform State (.tfstate) file. Note that as of the current version, pruning for HCL files is not yet supported and will return an error.
To use the command, provide the path to the file as a positional argument. You can optionally use the --canonicals flag to assign random names to resources during the pruning process (e.g., transforming aws_lb.front into aws_lb.123).
inframap prune state.tfstateThe inframap CLI provides the following subcommands:
generate: (Implicitly used via root logic) Generates the graphical view.prune: Prunes the graph.version: Displays the current version of inframap.