IBM Support

Using -var with Terraform plan through the CLI

Troubleshooting


Problem

When using the remote backend with the Terraform CLI, attempting to pass variables directly to the terraform plan command using the -var flag results in the following error:

Error: Run variables are currently not supported

Cause

This error occurs because the legacy remote backend configuration does not support passing run variables directly from the command line. The ability to use the -var flag with remote operations was introduced in Terraform v1.1 with the cloud block for HCP Terraform cloud integration.

  • Terraform Versions below 1.1: Do not support direct usage of -var with the remote backend.
  • Terraform Versions 1.1 and higher: Support -var with remote operations when the configuration uses the cloud block instead of the remote backend.

Solutions

There are two primary solutions depending on your version of Terraform.

Solution 1: For Terraform Versions Below 1.1

For older versions of Terraform using the remote backend, you must define variables using a file or through the web UI.

  1. Use a .auto.tfvars file: Create a file named terraform.auto.tfvars or any file ending in .auto.tfvars in your configuration directory. Terraform automatically loads variables from these files.

    Add your variable definitions to the file.

    ## terraform.auto.tfvars
    
    example_variable_name = "value"
  2. Set Workspace Variables in the UI: Define the variables directly in your HCP Terraform or Terraform Enterprise workspace. These variables are automatically available to all runs in that workspace.

After using one of these methods, run terraform plan without the -var flag.

$ terraform plan

Solution 2: For Terraform Versions 1.1 and Higher

For modern versions of Terraform, update your configuration to use the cloud block for HCP Terraform cloud integration. This configuration allows you to pass variables directly from the CLI.

Update your backend configuration.

terraform {
  cloud {
    organization = "your-organization"

    workspaces {
      name = "your-workspace"
    }
  }
}

Once the cloud block is configured, you can use the -var flag as expected.

$ terraform plan -var="example_variable_name=value"

Additional Information

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":"","label":""}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Historical Number

36097921048339

Document Information

Modified date:
16 March 2026

UID

ibm17265587