<p>My solution:</p>

<pre><code>├── main.tf
├── modules
│   ├── cluster1
│   │   ├── cluster1.tf
│   │   ├── main.tf
│   │   ├── output.tf
│   │   └── variables.tf
│   ├── cluster2
│   │   ├── cluster.tf
│   │   ├── main.tf
│   │   ├── output.tf
│   │   └── variables.tf
│   └── trafficmanager
│       ├── main.tf
│       ├── output.tf
│       ├── trafficmanager.tf
│       └── variables.tf
├── README.md
└── variables.tf
</code></pre>

<p>in order for me to create a Azure k8s clusters, each cluster requires service principal id and secret. i would be very interested to see some examples on how how to pass environment variables containing service principal and secret to each cluster.</p>

<p>Terraform will read environment variables in the form of TF_VAR_name to find the value for a variable. For example, the TF_VAR_access_key variable can be set to set the access_key variable.</p>

<h2>Example</h2>

<pre><code>export TF_VAR_region=us-west-1 # normal string
export TF_VAR_alist='[1,2,3]' # array
export TF_VAR_amap='{ foo = "bar", baz = "qux" }' # map
</code></pre>

<p>Pass module to terraform module</p>

<pre><code>variable "region" {}
variable "alist" {}
variable "map" {}

module "test" {
  source = "./module/testmodule" # module location
  region = "${var.region}"
  list   = "${var.alist}"
  map    = "${var.map}"
}
</code></pre>

<p>More information in <a href="https://www.terraform.io/docs/configuration/environment-variables.html#tf_var_name" rel="nofollow noreferrer">this</a> link and some <a href="https://www.terraform.io/docs/configuration/environment-variables.html#tf_var_name" rel="nofollow noreferrer">example</a>  </p>
