How to configure provisioner via module instance?


i just am not able to find out how this should work - and I read the documentation.

in my module I have

terraform {
  required_version = ">= 1.0.0"
  required_providers {
    proxmox = {
      source  = "Telmate/proxmox"
      version = ">= 2.9.11"
      configuration_aliases = [proxmox.root]

And the in my infrastructue part e.g. I’ve got

provider "proxmox" {
  alias  = "root"
  pm_log_enable = true
  pm_log_file   = "/tmp/terraform-plugin-proxmox.log"
  pm_debug      = true
  pm_log_levels = {
    _default    = "debug"
    _capturelog = ""
module "test_vm" {
  providers = {
    proxmox = proxmox.root

  count = 1

And what I get is

│ Error: Missing required provider configuration
│   on line 12:
│   12: module "test_vm" {
│ The child module requires an additional configuration for provider telmate/proxmox, with the local name "proxmox.root".
│ Refer to the module's documentation to understand the intended purpose of this additional provider configuration, and then add an entry for proxmox.root in the "providers" meta-argument in the module block to choose which provider
│ configuration the module should use for that purpose.
│ Error: Provider type mismatch
│   on line 14, in module "test_vm":
│   14:     proxmox = proxmox.root
│ The local name "proxmox.root" in the root module represents provider "hashicorp/proxmox", but "proxmox" in module.test_vm represents "telmate/proxmox".
│ Each provider has its own distinct configuration schema and provider types, so this module's "proxmox" can be assigned only a configuration for telmate/proxmox, which is not required by module.test_vm.

As you can see, I absolutely don’t understand how this works…

Please don’t send me the official documentation with aws examples, I’ve read that and it didn’t help.

Does somebody have any idea, how this should look like ?
Thank you very much.

Hi @haagen6000,

The errors are indicating 2 problems here. The first is that the module requires a provider named proxmox.root, but you are assigning the provider configuration to the name proxmox. I think you want to reverse that assignment, or if the module requires multiple configurations, you need to assign those separately.

The second is because the root module is missing its required_providers block declaring the source of the proxmox provider, so Terraform is assuming the provider is from the hashicorp/ namespace. Add the required_providers block to the root module so that Terraform can locate the correct provider.

In addition, if your module only requires one instance of the proxmox provider, it would probably be better if you did not use a provider configuration alias in your module at all.