https://platformengineering.org logo
#terraform
Title
# terraform
a

Arthur Busser

11/04/2022, 6:49 PM
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
tree
-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 😅
k

Kacper Twardowski

11/04/2022, 10:14 PM
do you think it can allow to make diagrams of infra? somehow?
n

nickhats

11/05/2022, 12:58 AM
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
a

Arthur Busser

11/05/2022, 9:30 AM
@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.
l

Luca Pasquali

11/07/2022, 1:13 AM
I was actually thinking about this over the weekend "is there a tool that can visualise my Terraform dependencies"? Perfect timing! 😄
s

Shem

11/14/2022, 5:34 AM
I've used this tool previously https://github.com/28mm/blast-radius, not sure if it's compatible with the latest version of terraform
a

antoine meynard

11/14/2022, 10:33 AM
It’s a great idea ! Does your tool work with module sourced from a git repository ? @Arthur Busser
a

Arthur Busser

11/14/2022, 12:36 PM
@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
tftree
🎉 https://github.com/busser/tftree
@Alexander Belanger 😉
79 Views