IBM Cloud Docs
Enabling Terraform logs by using the CLI

Enabling Terraform logs by using the CLI

Terraform uses environment variables to customize its behavior, which includes enabling Terraform logs. You can set an environment variable to take advantage of Terraform logs to debug unexpected issues with your code. Terraform reads environment variables and applies them at runtime.

Complete these steps if you use IBM Cloud projects to deploy architectures and want to enable Terraform logs. If you use an IBM Cloud Schematics workspace to execute Terraform without an IBM Cloud project, go to Using environment variables with workspaces for more information.

Before you begin

Setting the environment variable

  1. Log in to the IBM Cloud CLI and select your account:

    ibmcloud login
    
  2. Set the environment variable by running the ibmcloud project config-update command, specifying the project ID, configuration ID, and a name and value for the environment variable:

    ibmcloud project config-update --project-id PROJECT_ID --id CONFIG_ID --definition-settings "{\"ENV_NAME\":\"ENV_VALUE\"}"
    

    The following example adds the TF_LOG environment variable to enable Terraform logs:

    ibmcloud project config-update --project-id PROJECT_ID --id CONFIG_ID --definition-settings "{\"TF_LOG\":\"debug\"}"
    

    For a full list of command options, go to ibmcloud project config-update.

Other environment variables are supported in addition to TF_LOG. For more information, see the List of Terraform environment variables.