title: how to pass environment variables to terraform modules
body: <p>i am relatively new to terraform and looking for some help here! i want to refer a module and have it deployed across multiple AWS regions. I also want to pass few environment variables into the module something like this:</p>
  
  <pre><code>module "aws-eu-central-1" {
    source="git::https://&lt;git-repo-url&gt;"
    export TF_VAR_REGION="eu-central-1"
    export TF_VAR_TABLE_NAME="euc-accounts"
    export TF_VAR_ES_ENDPOINT="euc-elasticsearch"
    export TF_VAR_LOG_LEVEL="INFO"
  }
  
  module "aws-eu-west-1" {
    source="git::https://&lt;git-repo-url&gt;"
    export TF_VAR_REGION="eu-west-1"
    export TF_VAR_TABLE_NAME="euw-accounts"
    export TF_VAR_ES_ENDPOINT="euw-elasticsearch"
    export TF_VAR_LOG_LEVEL="INFO"
  }
  
  module "aws-eu-west-2" {
    source="git::https://&lt;git-repo-url&gt;"
    export TF_VAR_REGION="eu-west-2"
    export TF_VAR_TABLE_NAME="euw-accounts"
    export TF_VAR_ES_ENDPOINT="euw-elasticsearch"
    export TF_VAR_LOG_LEVEL="INFO"
  }
  </code></pre>
  
  <p>i want my source code to get deployed across these regions and want to pass the environment variables to the module. how this can be done? thanks for the help!</p>