DEV Community

Vidyasagar SC Machupalli
Vidyasagar SC Machupalli

Posted on

Tools to Visualize your Terraform plan

It all started with this code sample with Terraform scripts

For starters,Terraform is open-source software, developed by HashiCorp, that enables predictable and consistent provisioning of IBM Cloud platform, classic infrastructure, and VPC infrastructure resources by using a high-level scripting language. You can use Terraform to automate your IBM Cloud resource provisioning, rapidly build complex, multi-tier cloud environments, and enable Infrastructure as Code (IaC).

Think of a scenario in which you are revisiting your own Terraform scripts and scratching your head to understand what resources it provisions.

To simplify this, there is an in-built Terraform command



terraform graph


Enter fullscreen mode Exit fullscreen mode

The terraform graph command is used to generate a visual representation of either a configuration or execution plan. The output is in the DOT format, which can be used by GraphViz to generate charts.

You can use the command to generate a .png file from the dot output



terraform graph -type=plan | dot -Tpng > graph.png


Enter fullscreen mode Exit fullscreen mode

or



terraform graph -type=plan | dot -Tpng -o graph.png


Enter fullscreen mode Exit fullscreen mode

If there are too many resources, then the graph will look something like this.

Alt Text

As you can see, readability is a challenge and also there are extra nodes in the graph that are not required. So, you need better tools to visualize your Terraform plan.

Blast radius

Blast Radius is a tool for reasoning about Terraform dependency graphs through interactive visualizations. Awesome tool but couldn't make it work with the newer versions of Terraform. As per the Dockerfile in the respective repository and the comments in the issues, the last Terraform version that worked fine was 0.12.x.

Terraform Visual

Terraform Visual is a simple but powerful tool to help you understand your Terraform plan easily.

Alt Text

Click here to see the large image

Needs additional steps like generating plan.dot file and then plan.json file. but, a pretty good tool for any version of Terraform.

Inframap

Inframap reads your tfstate or HCL to generate a graph specific for each provider, showing only the resources that are most important/relevant.

If you know any other visualization tools, please drop in a comment below and would love to give it a try 😄

Top comments (2)

Collapse
 
sorincostea profile image
Sorin Costea

It's a pity Inframap only works with older TF versions - who would downgrade for that only? And VisualT only shows the plan, while I'm more interested by the state (and I'm a little bit wary of the simplifications it does)...

Collapse
 
vidyasagarmsc profile image
Vidyasagar SC Machupalli

Same with other awesome Terraform tools like prettyplan.chrislewisdev.com/ and github.com/coinbase/terraform-land...