Create diagram using Terraform and Graphviz

Everton Araújo
1 min readNov 24, 2023

--

Here are the basic steps to create a diagram of your infrastructure using Graphviz and Terraform:

Install Graphviz: If you don’t already have it installed, you can get it from https://graphviz.org/download/ and follow the installation instructions for your operating system.

Generate a DOT file: DOT is a graph description language used by Graphviz. You can generate a DOT file with the dependencies of your Terraform infrastructure using the terraform graph command. For example:

terraform graph > terraform.dot

This will create a file called terraform.dot containing the DOT representation of Terraform resource dependencies.

Convert DOT file to a graph: Use Graphviz to convert the DOT file to a graph. You can do this using the following command:

dot -Tpng terraform.dot -o terraform.png

This will create a PNG file called terraform.png that represents the graphic of your infrastructure.

View the chart: Open the terraform.png file in an image viewer or web browser to view the diagram of your Terraform infrastructure.

Source: https://graphviz.org/

--

--

Everton Araújo
Everton Araújo

No responses yet