Variables: Why is Terraform prompting for values when running Terraform Plan?

Reading Time: < 1 minute

Issue

I declared multiple variables in a “terraform.tfvars” file, but when I ran “Terraform plan”, it insisted that I “Enter a value”. This is far from desired:

Note: In this example, the state file is stored locally.

Fix

There could be a few reasons why this occurs, and there is a current open issue here, which is somewhat similar. In my case, however, it was a simple fix. The terraform.tfvars file was not in the same directory as the main.tf and variables.tf files!

Once the file had been moved to the correct directory, I ran:

terraform apply

It worked as expected:

Leave a Reply

Your email address will not be published. Required fields are marked *