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
- Install the IBM Cloud CLI plug-in.
- Install the IBM Cloud Projects CLI plug-in.
- Make sure that you have the Editor role on the IBM Cloud Projects service. For more information, go to Assigning access to projects.
Setting the environment variable
-
Log in to the IBM Cloud CLI and select your account:
ibmcloud login -
Set the environment variable by running the
ibmcloud project config-updatecommand, 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_LOGenvironment 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.