inframap

repository·master·Indexed 24 days ago

https://github.com/cycloidio/inframap

A 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.

Tokens
874
Snippets
2
Records
8
Agent score
85%

What's inside inframap

  1. Configure `generate` command flags

    master

    The generate command supports several flags to control how the graph is constructed and rendered:

    FlagTypeDefaultDescription
    --printerstringdotThe type of printer to use for the output. Supported types are listed by running inframap generate --help.
    --rawbooleanfalseIf 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.
    --cleanbooleantrueIf set, the generated graph will not include any nodes that do not have a connection/edge.
    --connectionsbooleantrueIf set, applies provider logic to remove resources that are not nodes.
    --show-iconsbooleantrueToggles the display of icons on the printed graph.
    --external-nodesbooleantrueToggles the addition of external nodes like im_out (used to show ingress connections).
    --description-filestring""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-namesbooleanfalseIf set, the tool attempts to read node names from tags, labels, and other sources instead of using canonical names.
  2. Configure inframap input type with --hcl and --tfstate

    master

    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.
  3. Use the `generate` command to create infrastructure graphs

    master

    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:

    • From a file: inframap generate [FILE]
    • From stdin: cat [FILE] | inframap generate
    inframap generate state.tfstate
    cat state.tfstate | inframap generate
  4. Prune TFState or HCL files with the prune command

    master

    The 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.tfstate