<p>You might be able to do something with the <a href="https://www.terraform.io/docs/language/resources/provisioners/local-exec.html" rel="nofollow noreferrer">local-exec Provisioner</a> to push the information out to an external script or file which you could monitor separately during the run.</p>
<p>The issue you might encounter is the run order, HCL isn't processed top to bottom like a &quot;traditional&quot; programming language, it works out a dependency tree for the resources it is creating, so might not run the local-exec when you'd expect them to be run.</p>

CC BY-SA 4.0
2021-05-13T10:45:33.440Z
That's a good shout / a feature I'd not been aware of - thank-you.  I've only upvoted rather than flagging as a solution since it's a workaround with a few side effects (e.g. creates a dependency on anyone using the module to have the required interpreter installed to meet this non-functional requirement), but will definitely have a play with this idea next time I hit this type of scenario.
JohnLBevan
CC BY-SA 4.0
2021-05-13T10:35:45.887Z
2021-05-13T10:35:45.887Z
Alastair Montgomery
<p>Is there any way to include verbose / debugging output in Terraform / Terragrunt?</p>
<p>I'm new to the language, and often struggle with knowing exactly what's going on.  It would be helpful for me to be able to inspect certain values; e.g. to confirm that locals &amp; variables have the values I expect, to get the ids of created components, etc.</p>
<p>I can include such info by creating outputs and assigning values there; but if I'm debugging a module I then have to include the output in the module's output, and again in the calling code's output for it to be visible; then have to delete those entries before delivering the solution.</p>
<p>I'd like a solution more like C#'s <code>Debug.WriteLine(/*...*/)</code> or PowerShell's <code>Write-Verbose #...</code> i.e. somewhere I can say what value I'd like to inspect, but have that output only show in the terminal when run with verbose output enabled, so these statements can be toggled on when needed, rather than impacting the delivered solution.</p>
<p>Does anything like this exist in the language?  So far I've found nothing documented or by Googling.</p>
<p>Note: The <code>TF_LOG</code> environment variable documented <a href="https://www.terraform.io/docs/internals/debugging.html" rel="nofollow noreferrer">here</a> is helpful for providing more info on what's going on under the covers; but only allows you to see predefined output; not to push your own content to the output stream.</p>

<terraform><terraform-module><terraform-workspace>
Include verbose output in terraform/terragrunt
JohnLBevan
# Include verbose output in terraform/terragrunt

(Asked by: username_0 on 2020-07-15)

Is there any way to include verbose / debugging output in Terraform / Terragrunt?

I'm new to the language, and often struggle with knowing exactly what's going on. It would be helpful for me to be able to inspect certain values; e.g. to confirm that locals & variables have the values I expect, to get the ids of created components, etc.

I can include such info by creating outputs and assigning values there; but if I'm debugging a module I then have to include the output in the module's output, and again in the calling code's output for it to be visible; then have to delete those entries before delivering the solution.

I'd like a solution more like C#'s `Debug.WriteLine(/*...*/)` or PowerShell's `Write-Verbose #...` i.e. somewhere I can say what value I'd like to inspect, but have that output only show in the terminal when run with verbose output enabled, so these statements can be toggled on when needed, rather than impacting the delivered solution.

Does anything like this exist in the language? So far I've found nothing documented or by Googling.

Note: The `TF_LOG` environment variable documented [here](https://www.terraform.io/docs/internals/debugging.html) is helpful for providing more info on what's going on under the covers; but only allows you to see predefined output; not to push your own content to the output stream.

**Tags:** terraform, terraform-module, terraform-workspace


---

## 1 answers

### Answer by username_1 on 2021-05-13. Score: 1

You might be able to do something with the [local-exec Provisioner](https://www.terraform.io/docs/language/resources/provisioners/local-exec.html) to push the information out to an external script or file which you could monitor separately during the run.

The issue you might encounter is the run order, HCL isn't processed top to bottom like a "traditional" programming language, it works out a dependency tree for the resources it is creating, so might not run the local-exec when you'd expect them to be run.

> **Comments:**
> **username_0**: That's a good shout / a feature I'd not been aware of - thank-you.  I've only upvoted rather than flagging as a solution since it's a workaround with a few side effects (e.g. creates a dependency on anyone using the module to have the required interpreter installed to meet this non-functional requirement), but will definitely have a play with this idea next time I hit this type of scenario.  

---

