azure – terraform plan -var-file= is not setting varibles

I have terraform project with two terraform.tfvars files.
Inside terraform.tfvars there are e.g:

location                 = "northeurope"
resource_group_name      = "michal_resource_group"

I run terraform init and get message: Terraform has been successfully initialized! so then I run:

terraform plan -var-file=C:\Users\Dev\repo\terraform-dep\terraform\TEST\terraform.tfvars

and it also finishes without any errors:

Plan: 5 to add, 0 to change, 0 to destroy.

but at this point I think that my variables from terraform.tfvars are not used because when I try terraform apply it says:

var.location
    Location to create the Azure resources.
    Enter a value:

when I type manually norteurope it asks about var.resource_group_name.

I also tried to use:

terraform console
> var.location
(known after apply)

so it doesn’t help at all.

What is the problem here? I am sure at terraform plan stage it looks at my ‘terraform.tfvars’ file because if I put there wrong values it fails.

Read more here: Source link