title: Combining two existing Terraform states as modules
body: <p>Right now I have a Terraform project consisting of multiple directories:</p>
  
  <pre><code>root
  |- stack
  |- applications
     |- app1
     |- app2
     |- app3
  </code></pre>
  
  <ul>
  <li><code>Stack</code> contains all of the common dependencies for the apps.</li>
  <li><code>app1</code>, <code>app2</code>, and <code>app3</code> use remote state to refer to <code>stack</code> resources.</li>
  <li>I currently have to run <code>terraform apply</code> in each of the four directories separately with separate <code>.tfvars</code>. (This was originally by design.)</li>
  </ul>
  
  <p>I would like to refactor this project with a single <code>.tf</code> file in the root directory and the <code>stack</code>/<code>app*</code> directories as modules. I know how to do that just fine from a TF standpoint, but since this project is already deployed in two different environments, I'm trying to figure out the best way to migrate my existing <code>stack/app*</code> resources into a new combined state file or at least automate all the <code>terraform import</code> commands I'm going to need to run.</p>
  
  <p>Any ideas?</p>