-->

DEVOPSZONES

  • Recent blogs

    How to Debug Terraform on Visual Studio Code on Windows

     Terraform has detailed logs which can be enabled by setting the TF_LOG environment variable to any value. This will cause detailed logs to appear on stderr. We can set this environment variable in windows either through Powershell or Sysytem Properties dialog box. 

    You can set TF_LOG to one of the log levels TRACEDEBUGINFOWARN or ERROR to change the verbosity of the logs.

    Setting TF_LOG to JSON outputs logs at the TRACE level or higher, and uses a parseable JSON encoding as the formatting.

    Through Sysytem Properties:

    1. Click on Search ICON on the windows Task Bar.

    2. Search for "env" .

    Edit the system enviornment variables
    Edit the system enviornment variables

    3. Click on the "Edit the system enviornment variables" .

    4. The in the System Properties Dilog box Click on "Enviornment variable Button".

    Enviornment variable Button
    Enviornment variable Button

    5. In the Next Dilog Click on "New" to Enter "Variable Name" and "Variable value" as given in the screenshot.

    set Enviornment variable
    Set Enviornment variable
    6. Click on "OK" Once done.

    7. Now Close the Powershell Window and Start Again. Then Check again if the environment variable has taken effect or not. 

    If you have chocolatey(choco) Installed then you do not need to close the Powershell. You can run "RefreshEnv.cmd" to take the new enviornment variable effected.

    Refresh Enviornment Variable
    Refresh Enviornment Variable


    Check_enviornment_variable
    Check_enviornment_variable


    Powershell:

    When setting an environment variable, you should be explicit that it is an environment variable by using the $Env: notation:

    PS Env:/> $Env:TF_LOG = "INFO"
    PS Env:/> Get-ChildItem TF_LOG
    INFO

    No comments