IBM Support

How to enable logging for Terraform Stacks

How To


Summary

This guide provides instructions for enabling the logging for Terraform Stacks in Terraform Enterprise, HCP Terraform and the Terraform CLI.
Enabling these logs is essential for debugging complex orchestration issues, component dependency errors within a Stack, etc.

Objective

The objective is to capture detailed TRACE logs to troubleshoot failed deployment runs or configuration issues in Terraform Stacks. These logs provide a line-by-line execution history of how Terraform processes .tfcomponent.hcl and .tfdeploy.hcl files.

Environment

  • HCP Terraform (Any tier with Stacks enabled)
  • Terraform Enterprise (2.0.0 or later)
  • Terraform CLI (v1.13.0 or later)

Steps

Method 1: Enable "Debug Logging" via Stack Settings (UI of HCP Terraform / Terraform Enterprise)

This method enables the logging for all operations within the specific Stack, until the setting is disabled.

  1. Navigate to the Stacks page in your HCP Terraform / Terraform Enterprise organization.

  2. Select the specific Stack you wish to debug.

  3. Click on Settings in the left-hand navigation menu, then select General.

  4. Locate the Debugging Mode section.

  5. Toggle the Enable Debugging Mode option to On.

  6. Click Save settings. Subsequent deployment runs will now generate detailed logs.

  7. To download the file, navigate to failed operation -> Inspect run data -> Download plan debug log (or Download apply debug log, depending on operation where Stack failed).

  8. The file in .log (plain-text format) will be downloaded to your machine.

  9. After you finish debugging, uncheck Enable Debugging Mode option and save the changes to disable the logging.

 

Method 2: Enable via API call (HCP Terraform UI / Terraform Enterprise)

If you are creating or updating a Terraform Stack via API, the logging can be enabled by including the attribute debugging-mode: true in your request payload.

It has a similar effect as the UI method described above - all operations within the specific Stack will have the logging enabled and after reproducing the issue, you can download the logs for further analysis.

 

Method 3: Enable for Terraform CLI

When using the terraform stacks commands locally, you can enable logging directly in your terminal session.

For Unix, Linux, or macOS:

  1. Set the TF_LOG environment variable to TRACE:

    $ export TF_LOG="TRACE"
  2. Run the desired terraform stacks command you wish to debug. Redirect standard output and standard error to a log file using 2>&1 and disable ANSI color escape sequences with the -no-color flag:

    $ terraform stacks deployment-run approve-all-plans -deployment-run-id <id> -no-color 2>&1 | tee output.log
  3. After you finish the debugging, unset the variable:

    $ unset TF_LOG

For Windows (PowerShell):

  1. Set the TF_LOG environment variable to TRACE:

    $Env:TF_LOG="TRACE"
  2. Run the desired terraform stacks command you wish to debug. Redirect standard output and standard error to a log file using 2>&1 and disable ANSI color escape sequences with the -no-color flag:

    $ terraform stacks deployment-run approve-all-plans -deployment-run-id <id> -no-color 2>&1 | Tee-Object -FilePath output.log
  3. After you finish the debugging, unset the variable:

    $Env:TF_LOG=""

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB77","label":"Automation Platform"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSGH5YK","label":"IBM Terraform Self-Managed"},"ARM Category":[{"code":"a8mgJ0000000DwXQAU","label":"Terraform-\u003EStacks"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"and future releases;2.0.0"}]

Document Information

Modified date:
01 May 2026

UID

ibm17271408