title: Terraform common variable usage in modules
body: <p>I am writing terraform script to create ASG on AWS. I tried to create it with terraform <code>module</code> to have a more reusable code. The problem is when I want to use variable from <code>common-variable.tfvars</code> on the module tf files, it keeps saying it is undefined and need to be declared. This way, the module will be less reuseable  .</p>
  
  <p>Here is an example</p>
  
  <pre><code>root
  |
  |___project 1
  |     |_____ main.tf
  |     |_____ common-variable.tfvars
  |
  |___ modules
        |
        |_____ a-module
                   |______ main.tf
  </code></pre>
  
  <p>So inside project 1 common-variable.tfvars, basically it looks like this</p>
  
  <pre><code>variable "a" { 
      description = "a variable"
      default = "a" 
  }
  
  variable "b" { 
      description = "a variable"
      default = "b" 
  }
  </code></pre>
  
  <p>Inside a-module / main.tf looks like this </p>
  
  <pre><code>variable "name" {}
  
  resource "aws_autoscaling_group" "asg-1" {
      name = "${var.a}"
      ...
  }
  </code></pre>
  
  <p>When I do terraform init, it says </p>
  
  <pre><code>resource 'aws_autoscaling_group.asg-1' config: unknown variable 
  referenced: 'a'. define it with 'variable' blocks
  </code></pre>
  
  <p>Any idea how i can use this common variable from within the module main .tf?</p>
  
  <hr>
  
  <p>Update</p>
  
  <p>I managed to pass <code>terraform init</code> by redeclaring the variable in each module. However, when i run <code>terraform plan</code>, this kind of error appears <code>invalid value "common-variable.tfvars" for flag -var-file: multiple map declarations not supported for variables</code></p>