title: declare a variable using `execute` Interpolation in Terraform
body: <p>I want to declare a a sub-string of a variable to another variable. I tested taking a sub-string using terraform console.  </p>
  
  <pre><code>&gt; echo 'element(split (".", "10.250.3.0/24"), 2)' | terraform console
  &gt; 3
  </code></pre>
  
  <p>my subnet is 10.250.3.0/24 and I want my virtual machine to get private IP address within this subnet mask 10.250.3.6. I want this to get automatically assign by looking at subnet address. What I've tried;</p>
  
  <p>test.tf</p>
  
  <pre><code>variable subnet {
    type = "string"
    default = "10.250.3.0/24"
    description = "subnet mask myTestVM will live"
  }
  
  variable myTestVM_subnet {
    type = "string"
    default = "10.250." ${element(split(".", var.trusted_zone_onpremises_subnet), 2)} ".6"
  }
  </code></pre>
  
  <p>And then I test it by</p>
  
  <pre><code>terraform console
  &gt;Failed to load root config module: Error parsing /home/anum/test/test.tf: At 9:25: illegal char
  </code></pre>
  
  <p>I guess its just simple syntax issue. but couldn't figure out what!</p>