Previously, we used an article started. Use Terraform to create and manage infrastructure resources with declarative configuration files (versionable code).
Before using the command terraform apply , we usually use terraform plan to view the execution plan, and the output execution plan is described in a text similar to "git diff". Here we will introduce how to understand the execution plan in a graphical but graphical way.

Terrafrom Graph

First of all, Terraform CLI tool comes with a subcommand- graph . The graph command is used to produce a graphical representation of the configuration and execution plan. The output is in DOT format. It can be Graphviz , for example, in the Linux terminal

❯ terraform graph | dot -Tsvg > graph.svg

tf-graph-1

For simple projects (comparison of managed resource objects), we can understand the relationship between resource objects through this graph. However, if a project manages a large number of resource objects, the graphics generated using graph will appear to be wrong and complicated, and the graphics files are also relatively large.

Then we will introduce an open source visualization tool.

Rover

Rover is an open source, interactive Terraform configuration and execution plan visualization tool. Through a web service, we can view the generated graphics through a browser and perform some interactive operations.

Rover is very easy to use. You can Release its Github project to run it, or run it through a Docker container.

If you use the downloaded binary file, put the downloaded binary file (such as rover_v0.2.2 ) in the PATH path, such as /usr/local/bin/rover , and then execute it in the folder of the Terraform project

❯ rover
2021/11/26 16:59:34 Starting Rover...
2021/11/26 16:59:34 Initializing Terraform...
2021/11/26 16:59:35 Generating plan...
2021/11/26 16:59:37 Parsing configuration...
2021/11/26 16:59:37 Generating resource overview...
2021/11/26 16:59:37 Generating resource map...
2021/11/26 16:59:37 Generating resource graph...
2021/11/26 16:59:37 Done generating assets.
2021/11/26 16:59:37 Rover is running on 0.0.0.0:9000

Run the rover command, which will perform the following operations

  1. Parse the configuration file in the directory and generate an execution plan file through Terraform plan
  2. Analyze plans and configuration files to generate 3 types of objects: resource overview (rso), resource map (map), resource graph (graph)
  3. Use the above 3 objects to convert them into interactive configuration and status views, run on the local 9000 port as a web server

We can visit http://localhost:9000/ through the browser to view the results of the visualization.

The whole page contains 4 parts

LEGEND -This part is a description of the legend

rover-legend

GRAPH -This part is the view of the entire resource relationship and status. You can use the mouse to zoom, drag, and select a resource

rover-graph

RESOURCES -The mapping list of resource files, showing the defined position of the resource in the configuration file, and you can also use the mouse to select

rover-resources

DETAILS -detailed information view, when using the mouse to select the GRAPH or RESOURCES view, the detailed information will be displayed here

rover-detailsj

By terraform graph with the graphics generated by 061a860ee26eb0, Rover showed a richer and more beautiful view, allowing us to fully understand the resources managed by the project in a visual way.

Attention issues

  1. Rover does not support projects that use "remote"-Backend, because there is no way to save the execution plan locally

Introduction video

HashiCrop engineers Tu Nguyen , that is, Rover developers, in Youtube released him on introduce Rover video


Also released at ROVER-TERRAFORM execution plan visualization tool

梦哲
74 声望58 粉丝

寻找人生的意义!