title: Create a nested object in terraform
body: <p>we are fetching key-value pairs from consul and we are trying to create an object of objects from the returning values.
  Basically, Consul returns the full path of the key, and we want to create a sub object from each recursive path.</p>
  <p>We get this -</p>
  <pre><code>{
    &quot;appPort&quot; = &quot;3000&quot;
    &quot;dockerAuth&quot; = &quot;regcred&quot;
    &quot;failureThreshold&quot; = &quot;3&quot;
    &quot;interval&quot; = &quot;10&quot;
    &quot;livenessProbe/failureThreshold&quot; = &quot;3&quot;
    &quot;livenessProbe/interval&quot; = &quot;10&quot;
    &quot;livenessProbe/path&quot; = &quot;/health/isalive&quot;
    &quot;livenessProbe/port&quot; = &quot;3000&quot;
    &quot;livenessProbe/startDelay&quot; = &quot;60&quot;
    &quot;livenessProbe/successThreshold&quot; = &quot;1&quot;
    &quot;livenessProbe/timeout&quot; = &quot;10&quot;
    &quot;path&quot; = &quot;/health/isalive&quot;
    &quot;port&quot; = &quot;3000&quot;
    &quot;pullPolicy&quot; = &quot;IfNotPresent&quot;
    &quot;readinessProbe/failureThreshold&quot; = &quot;3&quot;
    &quot;readinessProbe/interval&quot; = &quot;30&quot;
    &quot;readinessProbe/path&quot; = &quot;/health/isready&quot;
    &quot;readinessProbe/port&quot; = &quot;3000&quot;
    &quot;readinessProbe/startDelay&quot; = &quot;60&quot;
    &quot;readinessProbe/successThreshold&quot; = &quot;3&quot;
    &quot;readinessProbe/timeout&quot; = &quot;10&quot;
    &quot;replicaCount&quot; = &quot;3&quot;
    &quot;startDelay&quot; = &quot;60&quot;
    &quot;successThreshold&quot; = &quot;1&quot;
    &quot;timeout&quot; = &quot;10&quot;
  }
  </code></pre>
  <p>And we want to create this -</p>
  <pre><code>{
    &quot;appPort&quot; = &quot;3000&quot;
    &quot;dockerAuth&quot; = &quot;regcred&quot;
    &quot;failureThreshold&quot; = &quot;3&quot;
    &quot;interval&quot; = &quot;10&quot;
    &quot;livenessProbe&quot; = {
      &quot;failureThreshold&quot; = &quot;3&quot;
      &quot;interval&quot; = &quot;10&quot;
      &quot;path&quot; = &quot;/health/isalive&quot;
      &quot;port&quot; = &quot;3000&quot;
      &quot;startDelay&quot; = &quot;60&quot;
      &quot;successThreshold&quot; = &quot;1&quot;
      &quot;timeout&quot; = &quot;10&quot;
    }
    &quot;path&quot; = &quot;/health/isalive&quot;
    &quot;port&quot; = &quot;3000&quot;
    &quot;pullPolicy&quot; = &quot;IfNotPresent&quot;
    &quot;readinessProbe&quot;= {
      &quot;failureThreshold&quot; = &quot;3&quot;
      &quot;interval&quot; = &quot;30&quot;
      &quot;path&quot; = &quot;/health/isready&quot;
      &quot;timeout&quot; = &quot;10&quot;
      &quot;successThreshold&quot; = &quot;3&quot;
      &quot;port&quot; = &quot;3000&quot;
    }
    &quot;replicaCount&quot; = &quot;3&quot;
    &quot;startDelay&quot; = &quot;60&quot;
    &quot;successThreshold&quot; = &quot;1&quot;
    &quot;timeout&quot; = &quot;10&quot;
  }
  </code></pre>
  <p>Any Ideas?
  Thanks!</p>