Terraform: misleading tfvars error message: "Variables not allowed"

Created on 17 Mar 2020  ยท  1Comment  ยท  Source: hashicorp/terraform

Terraform Version

โฏ terraform -v
Terraform v0.12.23

Terraform Configuration Files

variables.tf:

variable "foo" {
  type = string
}

terraform.tfvars:

foo = bar

Debug Output

https://gist.github.com/steinybot/6d6fed5c27d7eb919a1c939521d57c20

Crash Output

Expected Behavior

Running terraform plan should have read the variables from terraform.tfvars.

Actual Behavior

โฏ terraform plan

Error: Variables not allowed

  on terraform.tfvars line 1:
   1: foo = bar

Variables may not be used here.


Error: No value for required variable

  on variables.tf line 1:
   1: variable "foo" {

The root module input variable "foo" is not set, and has no default value. Use
a -var or -var-file command line argument to provide a value for this
variable.

Steps to Reproduce

  1. terraform plan

Additional Context

References

config enhancement v0.12

Most helpful comment

So the underlying issue is that I forgot to quote the value.

It should be:

foo = "bar"

not:

foo = bar

But this is a really terrible error message to get for this type of mistake.

>All comments

So the underlying issue is that I forgot to quote the value.

It should be:

foo = "bar"

not:

foo = bar

But this is a really terrible error message to get for this type of mistake.

Was this page helpful?
0 / 5 - 0 ratings