When using a count, for_each, or depends_on statement with the module, terraform will throw an error message to the user and prevent using the module. In general with modules the configuration of a provider is generally avoided unless specific use case needs are required in order for the module to function properly. The following Hashicorp documentation discusses the topic and the implications and limitations imposed by configuring a provider inside a module.
Use a count, for_each, or depends_on with the module
Error Message
Initializing modules...
╷
│ Error: Module is incompatible with count, for_each, and depends_on
│
│ on ***.tf line 3, in module "vwan":
│ 3: count = var.****== "***" ? 1 : 0
│
│ The module at module.vwan.module.avm-ptn-virtualwan is a legacy module which contains its own local provider configurations, and so calls to it may not use the count, for_each, or depends_on arguments.
│
│ If you also control the module "registry.terraform.io/Azure/avm-ptn-virtualwan/azurerm", consider updating this module to instead expect provider configurations to be passed by its caller.
Remediation
Remove the following lines from the terraform.tf file
Summary
When using a count, for_each, or depends_on statement with the module, terraform will throw an error message to the user and prevent using the module. In general with modules the configuration of a provider is generally avoided unless specific use case needs are required in order for the module to function properly. The following Hashicorp documentation discusses the topic and the implications and limitations imposed by configuring a provider inside a module.
https://developer.hashicorp.com/terraform/language/modules/develop/providers#providers-within-modules
Reproduction
Use a count, for_each, or depends_on with the module
Error Message
Initializing modules...
Remediation
Remove the following lines from the terraform.tf file