title: What is the correct way to setup multiple logically organized sub folders in a terraform repo?
body: <p>Currently I am working on a infrastructure in azure that comprises of the following:</p>
  
  <ul>
  <li>resource group</li>
  <li>application gateway</li>
  <li>app service</li>
  <li>etc</li>
  </ul>
  
  <p>everything I have is in one single <code>main.tf</code> file which I know was a mistake however I wanted to start from there. I am currently trying to move each section into its own sub folder in my repo. Which would look something like this: </p>
  
  <pre><code>terraform-repo/
  ├── applicationGateway/
  │   ├── main.tf
  │   ├── vars.tf
  ├── appService/
  │   ├── main.tf
  │   └── vars.tf
  ├── main.tf
  └── vars.tfvars
  </code></pre>
  
  <p>However when I create this while trying to move over from the single file structure I get issues with my remote state where it wants to delete anything that isn't a part of the currently worked on sub folder. 
  For example if I wanted to run <code>terraform apply applicationGateway</code> I will get the following:</p>
  
  <pre><code>  # azurerm_virtual_network.prd_vn will be destroyed
  
  Plan: 0 to add, 2 to change, 9 to destroy.
  </code></pre>
  
  <p>What is the correct way to setup multiple logically organized sub folders in a terraform repo? Or do I have to destroy my current environment to get it to be setup like this ?</p>