title: Terraform - Use of environment variables in TF files
body: <p>I would like to use environment variables in my TF files. How can I mention them in those files?</p>
  
  <p><strong>I use Terraform cloud and define the variables in the environment variables section.</strong> Which means I don't use my cli to run terraform commands commands (no export TF_VAR &amp; no -var or -var-file parameter).</p>
  
  <p>I didn’t find any answer to this in forums nor in documentation.</p>
  
  <p><strong>Edit:</strong>
  Maybe if I'll elaborate the things I've done it will be much clear.</p>
  
  <p>So I have 2 environment variables named "username" and "password"</p>
  
  <p>Those variables are defined in the environment variables section in Terraform Cloud.</p>
  
  <p>In my main.tf file I create a mongo cluster which should be created with those username and password variables.
  In the main variables.tf file I defined those variables as:</p>
  
  <pre><code>variable "username" {
    type = string
  }
  
  variable "password" {
    type = string
  }
  </code></pre>
  
  <p>My main.tf file looks like:</p>
  
  <pre><code>module "eu-west-1-mongo-cluster" {
  ...
  ...
    username = var.username
    password = var.password
  }
  </code></pre>
  
  <p>In the mongo submodule I defined them in variables.tf file as type string and in the mongo.tf file in the submodule I ref them as var.username and var.password</p>
  
  <p>Thanks !</p>