Answers: <p>You define variables in <code>variables.tf</code> file. However, you can define inputs to these defined variables in a <code>.tfvars</code>(recommended) or any other files.</p>
  
  <blockquote>
    <p>Values for the input variables of a root module can be gathered in variable definition files and passed together using the -var-file=FILE option.</p>
    
    <p>For all files which match terraform.tfvars or *.auto.tfvars present in the current directory, Terraform automatically loads them to populate variables. If the file is located somewhere else, you can pass the path to the file using the -var-file flag. It is recommended to name such files with names ending in .tfvars.
    <a href="https://www.terraform.io/docs/configuration/variables.html#variable-files" rel="nofollow noreferrer">more...</a></p>
  </blockquote>
  
  <p>Make sure you are running <code>terraform plan</code> from the directory where the variable file resides. </p>
  
Answers: CC BY-SA 4.0
Answers: 2018-08-31T13:42:03.713Z
Answers: I do! It is in the same directory! The documentation says that I can use whatever filename is want, as long as I specify it in the -var-file. 
  
  The directory has the following files:
  
  
  create_instance.tf, general variables.tf, myvars.var
Answers: Peter
Answers: CC BY-SA 4.0
Answers: 2018-08-31T13:45:59.880Z
Answers: Yes, you could use whatever file name you want. The same command works for me, except if the file is missing, or probably running it from a different directory. Would you mind to paste exact output you get when you run the command?
Answers: atokpas
Answers: CC BY-SA 4.0
Answers: 2018-08-31T14:26:04.037Z
Answers: terraform  plan -var-file="my-vars.vars"
  
  invalid value "my-vars.vars" for flag -var-file: multiple map declarations not supported for variables
  Usage: terraform plan [options] [DIR-OR-PLAN]
Answers: Peter
Answers: CC BY-SA 4.0
Answers: 2018-08-31T14:32:06.230Z
Answers: Sorry, wrong output (I was in another directory, sorry).
  
  Here is what I get:
  
  terraform  plan -var-file=idm-vars.vars 
  Usage: terraform plan [options] [DIR-OR-PLAN]
  
    Generates an execution plan for Terraform.                                                                                                                           
  
    This execution plan can be reviewed prior to running apply to get a                                                                                                  
    sense for what Terraform will do. Optionally, ...
Answers: Peter
Answers: CC BY-SA 4.0
Answers: 2018-08-31T14:41:09.963Z
Answers: What do you get if you run the `plan` command without `-var-file` parameter?
Answers: atokpas
Answers: CC BY-SA 4.0
Answers: 2018-08-31T13:32:14.217Z
Answers: 2018-08-31T13:32:14.217Z
Answers: atokpas
Answers: <p>The problem was a typo in the var-file
  I had a double " in a value:</p>
  
  <pre><code>varname = ""value"
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2018-08-31T15:03:38.460Z
Answers: 2018-08-31T15:03:38.460Z
Answers: Peter
Body: <p>I try to lean terraform for usage with our AWS environment.
  I have created a .tf file and terraform init was successful. </p>
  
  <p>In the .tf file I have a number of variables that are populated via .var files (not <strong>.tfvar</strong>) because I want to assign values per instance/project etc.</p>
  
  <p>The problem is that when I run the command </p>
  
  <pre><code>terraform plan -var-file="myvars.var"
  </code></pre>
  
  <p>all I get is the terraform usage message. </p>
  
  <p>Where is my mistake?</p>
  
Tags: <terraform>
Title: Terraform plan -var-file="myvars.vars" does not run
UserDisplayName: Peter
ThreadText: # Terraform plan -var-file="myvars.vars" does not run
  
  (Asked by: username_0 on 2018-08-31)
  
  I try to lean terraform for usage with our AWS environment.
  I have created a .tf file and terraform init was successful.
  
  In the .tf file I have a number of variables that are populated via .var files (not **.tfvar**) because I want to assign values per instance/project etc.
  
  The problem is that when I run the command
  
  ```
  terraform plan -var-file="myvars.var"
  
  ```
  
  all I get is the terraform usage message.
  
  Where is my mistake?
  
  **Tags:** terraform
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-08-31. Score: 3
  
  You define variables in `variables.tf` file. However, you can define inputs to these defined variables in a `.tfvars`(recommended) or any other files.
  
  > Values for the input variables of a root module can be gathered in variable definition files and passed together using the -var-file=FILE option.
  >
  > For all files which match terraform.tfvars or \*.auto.tfvars present in the current directory, Terraform automatically loads them to populate variables. If the file is located somewhere else, you can pass the path to the file using the -var-file flag. It is recommended to name such files with names ending in .tfvars.
  > [more...](https://www.terraform.io/docs/configuration/variables.html#variable-files)
  
  Make sure you are running `terraform plan` from the directory where the variable file resides.
  
  > **Comments:**
  > **username_0**: I do! It is in the same directory! The documentation says that I can use whatever filename is want, as long as I specify it in the -var-file.   The directory has the following files:   create_instance.tf, general variables.tf, myvars.var  
  > **username_1**: Yes, you could use whatever file name you want. The same command works for me, except if the file is missing, or probably running it from a different directory. Would you mind to paste exact output you get when you run the command?  
  > **username_0**: terraform  plan -var-file="my-vars.vars"  invalid value "my-vars.vars" for flag -var-file: multiple map declarations not supported for variables Usage: terraform plan [options] [DIR-OR-PLAN]  
  > **username_0**: Sorry, wrong output (I was in another directory, sorry).  Here is what I get:  terraform  plan -var-file=idm-vars.vars  Usage: terraform plan [options] [DIR-OR-PLAN]    Generates an execution plan for Terraform.                                                                                                                               This execution plan can be reviewed prior to running apply to get a                                                                                                     sense for what Terraform will do. Optionally, ...  
  > **username_1**: What do you get if you run the `plan` command without `-var-file` parameter?  
  
  ---
  
  ### Answer by username_0 on 2018-08-31. Score: 0
  
  The problem was a typo in the var-file
  I had a double " in a value:
  
  ```
  varname = ""value"
  
  ```
  
  
  ---
  
  