Azure / terraform-azurerm-avm-ptn-virtualwan

MIT License
5 stars 11 forks source link

Bug: Provider configuration in module throws terraform error #3

Closed OmnipotentOwl closed 9 months ago

OmnipotentOwl commented 11 months ago

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...

╷
│ 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

provider "azurerm" {
  features {
    resource_group {
      prevent_deletion_if_contains_resources = false
    }
  }
}
khushal08 commented 9 months ago

WIP

khushal08 commented 9 months ago

@OmnipotentOwl Code changes have been pushed. Thanks for the feedback.