Hey everyone :wave: I recently joined a new compa...
# terraform
Hey everyone 👋 I recently joined a new company and wanted to understand how the Terraform codebase was organised. Understanding which module called which required moving through the entire codebase manually and didn’t provide the visual aid I needed to build a solid mental model of the codebase. So I wrote a
-like CLI that parses Terraform’s plan and displays the module call tree. It worked well and now I understand our codebase much better! See the screenshot below for a run on an example codebase (not my company’s). As members of the platform engineering community and fellow Terraform users, how interested would you be for me to make this tool open source? No point in going beyond this proof of concept if nobody will use it anymore 😅
do you think it can allow to make diagrams of infra? somehow?
If you have the time to tweak the visual elements of this Python library (that piggybacks on graphviz) it makes it easy to create diagrams programmatically from a list of dictionaries https://diagrams.mingrammer.com/docs/getting-started/examples I have used this to quickly mock-up some network diagrams for PoC and swap IP addresses and hostnames as you need it, it has a lot of standard icons but you can use any png file. The beauty of it is you can loop through lists and "connect" the nodes together
@Kacper Twardowski In theory I could probably list resources in the tree and not just modules, but I wouldn’t call that a diagram. This tool only displays the code’s call tree, not the relationship between the resources themselves. You can refactor your codebase to have a completely different module call tree without changing a single resource in the cloud, so I think the two are orthogonal.
I was actually thinking about this over the weekend "is there a tool that can visualise my Terraform dependencies"? Perfect timing! 😄
I've used this tool previously https://github.com/28mm/blast-radius, not sure if it's compatible with the latest version of terraform
It’s a great idea ! Does your tool work with module sourced from a git repository ? @Arthur Busser
@antoine meynard it does, although I haven’t tested it much in that use-case. There may be minor issues with how module source paths are computed/displayed
Hey all! I finally took the time to open source the tool. Introducing
🎉 https://github.com/busser/tftree
@Alexander Belanger 😉