cycloidio / inframap

Read your tfstate or HCL to generate a graph specific for each provider, showing only the resources that are most important/relevant.
MIT License
1.68k stars 95 forks source link

consider implementing a stdin source #228

Closed BogdanSorlea closed 8 months ago

BogdanSorlea commented 8 months ago

hey,

take scenario where one terraformer-generates tf files spread across folders and stuff, it would be great to have them visualised with inframap reading stdin or similar, so something like cat generated/aws/*/*.tf | inframap generate | dot -Tpng > map.png would be able to happen

xescugc commented 8 months ago

You can already use STDIN in Inframap, cat state.tfstate | inframap generate this is valid. OFC cat generated/aws/*/*.tf is not valid as it's not possible, but you can do inframap generate --hcl generate/aws/ and it'll read all the folder and if it's a module all the structure even if it has nested.

Could you try that?

BogdanSorlea commented 8 months ago

hey, thanks for the input - only afterwards I noticed the cat in the man

however, for my scenario the tool does not work - it's limited because of the way things are parsed / it relies on the dependency graph, whereas output from terraformer is very static (resources defined in complete isolation from one another, no references):

(☸️ |aws-platform-production-eu-west-1:platform)➜  stag_network_diagram cat generated/aws/subnet/terraform.tfstate | inframap generate
strict digraph G {

}
(☸️ |aws-platform-production-eu-west-1:platform)➜  stag_network_diagram cat generated/aws/vpc/terraform.tfstate | inframap generate
strict digraph G {

}
(☸️ |aws-platform-production-eu-west-1:platform)➜  stag_network_diagram cat generated/aws/subnet/*.tf | inframap --hcl generate
strict digraph G {

}
(☸️ |aws-platform-production-eu-west-1:platform)➜  stag_network_diagram cat generated/aws/vpc/*.tf | inframap --hcl generate
strict digraph G {

}
(☸️ |aws-platform-production-eu-west-1:platform)➜  stag_network_diagram
BogdanSorlea commented 8 months ago

I'll close this one, as it answers my question and the rest is outside the scope