Saving terraspace all graph --format text output

Hi BoltOps Community,

With terraspace all graph, when run with the default format, it will save the result to a .png file. But when we do terraspace all graph --format text, there isn’t an option to save the graph to a file.

Normally, I would just redirect the output to a file. e.g. terraspace all graph --format text > graph.txt. However, this didn’t work (at least for my case). But this worked terraspace all graph --format text > graph.txt 2>&1 (meaning that the graph was being written to stderr instead of stdout).

Again, ordinarily this might work in most cases. However, as previously reported in a different thread, we found that if we try to run terraspace all graph the first time (and the terraspace cache folder isn’t built), there are lots of warning messages about backend not being initialized and it requires the running of terraform init*

*I think doing a terraspace all init (when the cache folder doesn’t exists) still produces the warnings. But interestingly, doing a terraspace all validate (when the cache folder doesn’t exists) doesn’t produce the warning.

TLDR; I think I can work around the problems and save the text output of terraspace all graph --format text by doing

terraspace all validate
terraspace all graph --format text > graph.txt 2>&1

but thought I’d share it with everyone (and perhaps propose consideration for e.g. --out parameter to terraspace all graph) :slight_smile:

Many thanks,


Just a quick update…

I was looking through the forums and stumbled upon the Logging to stderr breaks Azure DevOps pipelines thread. So, following @xxbeanxx’s suggestion, I was able to output the graph (in text format) into stdout by doing the following:

Terraspace.configure do |config|
  logger =$stdout)
  config.logger = logger


1 Like