title: Terraform Import
body: <p>I have a Terraform environment with multiple subscriptions. My Directory structure looks in a simplified way like this</p>
  <pre><code>_Config
  ++SubScr1
  ++++terraform.tfvars
  ++SubScr2
  ++++terraform.tfvars
  
  _Modules
  ++general
  ++++rg_create
  ++++++main.tf
  ++++++output.tf
  ++++++variables.tf
  
  _Templates
  ++rg
  ++++main.tf
  ++++variables.tf
  
  maif.tf
  providers.tf
  variables.tf
  </code></pre>
  <p>Until now all was in Azure DevOps, we are now also working locally and syncing git.</p>
  <p>I've been able to create a CLI scripts that performs a 'az login', set environment variables and performs a terraform init. Working fine.</p>
  <p>A terraform plan also is working from the 'root' directory.</p>
  <p>But when I try to do a import of a (ex) resource group this fails complaining that azurerm_resource_group is not found, when I move to the subdirectory '_module\general\rg_create' then the system gives error on the fact thet other modules haven't been initialized..</p>
  <p>So I'm a bit confused.
  Might be I'm missing somewhere a concept, any help appreciated</p>
  <p>Error 1</p>
  <pre><code>    T:\_CommandLine&gt;CD \
  
   T:\&gt;TerraForm import -var-file=&quot;T:\_config\it-poc-int-01\core_000\terraform.tfvars&quot; azurerm_resource_group.rg /subscriptions/8dc72845-b367-4dcc-98f9-d9a4a933defc/resourceGroups/rg-poc-edw-999
      Error: resource address &quot;azurerm_resource_group.rg&quot; does not exist in the configuration.
      
      Before importing this resource, please create its configuration in the root module. For example:
      
      resource &quot;azurerm_resource_group&quot; &quot;rg&quot; {
        # (resource arguments)
      }
  </code></pre>
  <p>Or error 2</p>
  <pre><code>T:\_CommandLine&gt;CD \_Modules\general\rg_create
  
  T:\_modules\general\rg_create&gt;TerraForm import -var-file=&quot;T:\_config\it-poc-int-01\core_000\terraform.tfvars&quot; azurerm_resource_group.rg /subscriptions/8dc72845-b367-4dcc-98f9-d9a4a933defc/resourceGroups/rg-poc-edw-999
  ╷
  │ Error: Module not installed
  │
  │   on main.tf line 14:
  │   14: module &quot;subscription&quot; {
  │
  │ This module is not yet installed. Run &quot;terraform init&quot; to install all modules required by this configuration.
  ╵
  
  ╷
  │ Error: Module not installed
  │
  │   on main.tf line 18:
  │   18: module &quot;location&quot; {
  │
  │ This module is not yet installed. Run &quot;terraform init&quot; to install all modules required by this configuration.
  ╵
  
  ╷
  │ Error: Module not installed
  │
  │   on main.tf line 38:
  │   38: module &quot;rg_roles_aadgroups&quot; {
  │
  │ This module is not yet installed. Run &quot;terraform init&quot; to install all modules required by this configuration.
  ╵
  </code></pre>