title: Get type of a variable in Terraform
body: <p>Is there a way to detect the type of a variable in Terraform? Say, I have a module input variable of type <code>any</code>, can I do some kind of switch, depending on the type?</p>
  
  <pre><code>variable "details" {
    type = any
  }
  
  local {
    name = var.details.type == map ? var.details["name"] : var.details
  }
  
  </code></pre>
  
  <p>What I want to archive is, to be able to pass either a string as shorthand or a complex object with additional keys.</p>
  
  <pre><code>module "foo" {
    details = "my-name"
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>module "foo" {
    details = {
      name = "my-name"
      age = "40"
    }
  }
  </code></pre>
  
  <hr>
  
  <p><sup>I know this example doesn't make much sense and you would like to suggest to instead use two input vars with defaults. This example is just reduced to the minimal (non)working example. The end goal is to have a list of IAM policy statements, so it is going to be a list of lists of objects.</sup></p>