title: Terraform: dynamic attribute from variable (in splat syntax)
body: <p>In terraform HCL, is it possible to reference an object's attribute dynamically from a variable?</p>
  
  <p>I.e.:</p>
  
  <pre><code>variable "attribute" {
    type = "string"
  }
  
  data "terraform_remote_state" "thing" {
    not_really_important
  }
  
  output "chosen" {
    value = "${data.terraform_remote_state.thing.$var.attribute}"
  }
  </code></pre>
  
  <p>More specific to my situation, I'm looking to do this with the splat syntax:</p>
  
  <pre><code>variable "attribute" {
    type = "string"
  }
  
  data "terraform_remote_state" "thing" {
    count = 3 # really this is also a variable
    not_really_important
  }
  
  output "chosen" {
    value = "${data.terraform_remote_state.thing.*.$var.attribute}"
  }
  </code></pre>
  
  <p>I've tried things like <code>lookup(data.terraform_remote_state.thing, var.attribute)</code> and (for the splat problem) <code>lookup(element(data.terraform_remote_state.*, count.index), var.attribute)</code> but they both complain about my attribute reference being incomplete/in the wrong form.</p>