DEV Community

Cover image for an interactive Terraform graph

Posted on

an interactive Terraform graph

Photo by David Pisnoy on Unsplash

Terraform already has a graph command that can be used with dot to produce a svg graph. But this graph is not interactive.

Blast-radius is a tool producing a svg graph interactive in a web browser, based on Terraform graph. You can see online examples for many providers.

Alt Text

A warning about version

I have tried to use it before, but due to parsing issues during the upgrade from Terraform 0.11 to 012 (and the producing / integration of the new pyhcl library), i had to stop it. But now, it is working again (if you use Terraform 0.12 or higher )!

How to use it

You have to position yourself inside your project directory. See the docs to know where you should be.

The easiest way for me to use it, is through the Docker image.

Modifying the Dockerfile in this issue, you can easily set the terraform version you need. Create the dockerfile locally and build it.

Then, run the following command in your project directory (if it contains your .terraform):

docker run --rm -it -p 5000:5000 -v ${pwd}:/data --cap-add=SYS_ADMIN myDockerImageBasedOnBlastRadius --serve .

Now go to http://localhost:5000/ and you should see your graph.

Hope this helps !

Top comments (2)

dishantpandya profile image
Dishant Pandya

This tool is great when infrastructure is small, but doesn't work with complex infrastructure with multiple modules, nested into each other, with hundreds of variables and outputs. And afterall its with such large complex infrastructure we need such tools, the example templates are sufficiently small to understand them just from the code. Even for larger infrastructure one writing the templates won't need it for themselves, but to share the knowledge with other teams and managers.

stav profile image
Stav Sitnikov