title: Terraform Schema Elem Support Multiple Types?
body: <p>Can the Terraform Schema support multiple Schema types for an <code>Elem</code>? The problem I'm trying to solve is that the data from my external API is an array that has multiple types--some elements are strings and some are lists. For instance a value would look something like:</p>
  
  <pre><code>condition = [
      "and",
      [
          "contains",
          ["foo","bar","baz"],
          "website"
      ]
  </code></pre>
  
  <p>And then, I create my schema for that property to look something like this</p>
  
  <pre class="lang-golang prettyprint-override"><code>"condition": {
      Type:     schema.TypeList,
      Required: true,
      Elem: &amp;schema.Schema{
          Type: schema.TypeList,
      },
  },
  </code></pre>
  
  <p>But, when I run my test I get a message that says:</p>
  
  <pre><code>condition.0: should be a list
  </code></pre>
  
  <p>Which, this makes sense because my schema definition declares that every <code>Elem</code> should be a list. Is there a way to define multiple types for the <code>Elem</code>?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I've changed my <code>condition</code> field from the above to be </p>
  
  <pre><code>"condition_json": {
    Type:     schema.TypeString,
    Required: true,
  },
  </code></pre>
  
  <p>My <code>.tf</code> file is now using <code>jsonencode()</code> like so:</p>
  
  <pre><code>
  variable "condition_list" {
      default = [
          ["and"],
          ["contains",["path","payload","source"],"website"],
          ["contains",["path","headers","from","0","address"],"homer"]
      ]
  }
  resource "event_rule" "first" {
      condition_json = "${jsonencode(var.condition_list)}"
  }
  </code></pre>
  
  <p>When I build my struct for my event rule object, the <code>Condition</code> field is getting the value of <code>condition_json</code> like so:</p>
  
  <pre><code>Condition: d.Get("condition_json").([]interface{}),
  </code></pre>
  
  <p>Because my Condition field in the library interfacing with the API looks like:</p>
  
  <pre><code>Condition         []interface{} `json:"condition,omitempty"`
  </code></pre>
  
  <p>My problem is that I'm getting an error that </p>
  
  <pre><code>interface {} is string, not []interface {}
  </code></pre>
  
  <p>This message makes sense because I have the schema set to <code>TypeString</code> but, in my struct interfacing with the API I have <code>Condition</code> typed as <code>[]interface{}</code>. My question is, is there a way to cast d.Get("condition_json") to <code>[]interface{}</code> rather than assert?</p>
  
  <p>I'm obviously missing something, and I'm not sure what. :)</p>