title: If statement in terraform, using 2 different code blocks
body: <p>I have this codeblock</p>
  <pre><code>  launchpad_tmpl = {
      apiVersion = &quot;&lt;Link for the API&gt;&quot;
      kind       = &quot;mke&quot;
      spec = {
        mke = {
          adminUsername = &quot;admin&quot;
          adminPassword = var.admin_password
          installFlags : [
            &quot;--default-node-orchestrator=kubernetes&quot;,
            &quot;--san=${module.masters.lb_dns_name}&quot;,
          ]
        }
        hosts = concat(local.managers, local.msrs, local.workers, local.windows_workers)
      }
    }
  }
  </code></pre>
  <p>And I have another codeblock</p>
  <pre><code>  launchpad_tmpl = {
      apiVersion = &quot;&lt;Some link for the API&gt;&quot;
      kind       = &quot;mke&quot;
      spec = {
        mke = {
          adminUsername = &quot;admin&quot;
          adminPassword = var.admin_password
          installFlags : [
            &quot;--default-node-orchestrator=kubernetes&quot;,
            &quot;--san=${module.masters.lb_dns_name}&quot;,
          ]
        }
  
        msr = {
        ...some_code
        }
        hosts = concat(local.managers, local.msrs, local.workers, local.windows_workers)
      }
    }
  }
  </code></pre>
  <p>I want to tell terraform something like</p>
  <p>IF msr_count &gt;= 1 - Use second codeblock to run
  ELSE use the first one...</p>
  <p>Is it possible in Terraform Or I will need to make a wrapper somewhere?
  Thanks in Advance.</p>
  <p>UPDATE:::</p>
  <pre><code> Error: Inconsistent conditional result types
  
    on main.tf line 162, in output &quot;mke_cluster&quot;:
   162:   value = yamlencode(var.msr_count &gt; 0 ? local.msr_launchpad_tmpl : local.mke_launchpad_tmpl)
      |----------------
      | local.mke_launchpad_tmpl is object with 3 attributes
      | local.msr_launchpad_tmpl is object with 3 attributes
      | var.msr_count is 1
  
  The true and false result expressions must have consistent types. The given
  expressions are object and object, respectively.
  </code></pre>
  <p>This is the output when it placed like this:</p>
  <pre><code> mke_launchpad_tmpl = {
      apiVersion = &quot;API&quot;
      kind       = &quot;mke&quot;
      spec = {
        mke = {
          adminUsername = &quot;admin&quot;
          adminPassword = var.admin_password
          installFlags : [
            &quot;--default-node-orchestrator=kubernetes&quot;,
            &quot;--san=${module.masters.lb_dns_name}&quot;,
          ]
        }
        hosts = concat(local.managers, local.msrs, local.workers, local.windows_workers)
      }
    }
  
  
    msr_launchpad_tmpl = {
      apiVersion = &quot;API&quot;
      kind       = &quot;mke+msr&quot;
      spec = {
        mke = {
          adminUsername = &quot;admin&quot;
          adminPassword = var.admin_password
          installFlags : [
            &quot;--default-node-orchestrator=kubernetes&quot;,
            &quot;--san=${module.masters.lb_dns_name}&quot;,
          ]
        }
        msr = {
          installFlags : [
            &quot;--ucp-insecure-tls&quot;,
            &quot;--dtr-external-url ${module.msrs.lb_dns_name}&quot;,
          ]
          }
      hosts = concat(local.managers, local.msrs, local.workers, local.windows_workers)
      }
    }
    launchpad_tmpl = var.msr_count &gt; 0 ? local.msr_launchpad_tmpl : local.mke_launchpad_tmpl
  }
  
  output &quot;mke_cluster&quot; {
    value = yamlencode(local.launchpad_tmpl)
  }
  </code></pre>