title: Terraform 1.1.X: Using libvirt in child module
body: <p>I am trying to use libvirt in my child module, but I get an error.
  Code:</p>
  <pre><code>terraform {
  required_version = &quot;&gt;= 1.1.6&quot;
  required_providers {
    libvirt = {
      source  = &quot;dmacvicar/libvirt&quot;
      version = &quot;&gt;= 0.6.14&quot;
    }
  }
  }
  
  provider &quot;libvirt&quot; {
  uri   = &quot;qemu:///system&quot;
  alias = &quot;local&quot;
  }
  module &quot;my_local_kvm_module&quot; {
  
  source = &quot;../modules/KVM/kvm_vm&quot;
  providers = {
    libvirt = libvirt.local
  }
  some_vars=&quot;some_vals&quot;
  }
  </code></pre>
  <p>Error is quite strange:</p>
  <pre><code>The Terraform configuration must be valid before initialization so that
  Terraform can determine which modules and providers need to be installed.
  ╷
  │ Warning: Provider libvirt is undefined
  │ 
  │   on main.tf line 19, in module &quot;my_local_kvm_module&quot;:
  │   19:     libvirt = libvirt.local
  │ 
  │ Module module.my_local_kvm_module does not declare a provider named libvirt.
  │ If you wish to specify a provider configuration for the module, add an entry for libvirt in the
  │ required_providers block within the module.
  ╵
  
  ╷
  │ Error: Invalid type for provider module.my_local_kvm_module.provider[&quot;registry.terraform.io/hashicorp/libvirt&quot;]
  │ 
  │   on main.tf line 19, in module &quot;my_local_kvm_module&quot;:
  │   19:     libvirt = libvirt.local
  │ 
  │ Cannot use configuration from provider[&quot;registry.terraform.io/dmacvicar/libvirt&quot;].local for
  │ module.my_local_kvm_module.provider[&quot;registry.terraform.io/hashicorp/libvirt&quot;]. The given
  │ provider configuration is for a different provider type.
  
  </code></pre>
  <p>Looks like provider can't be found inside module, the same code works with just resource sections instead of module.</p>
  <p>Could You tell me how it should be configured ??</p>
  <p>Thanks for Your help.</p>
  <p>Best regards,
  Dawid</p>