You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have around 40-50 Azure subscriptions. A resource group should be deployed to each of the subscription. In each resource group backup vault and policies etc will furthermore added deployed (some of the vault are in different region deployed). To not repeat code, if created a module which runs in an for_each loop (in the module there is an other for_each loop for the vault/policies etc). The terraform code runs so far correct, with the limit that all resource groups are deployed in the same subscription.
Attempted Solutions
To bring more dynamic in to the code i've tried to add the resource provider in to the module and then add the right subscription id trough an variable to the module. terraform does not allow this procedure. Even if i add 40 resource provider in an provider.tf file i'm not able to change the subscription for each iteration of the module.
This is a big limitation to terraform.
Proposal
Make a more dynamic way of given an provider as input to an resource. The resources will be implemented by an module in an for_each loop. Would even love to have an more dynamic way to change subscription than creating 40 resource provider with aliases.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Current Terraform Version
Terraform v1.1.6
Use-cases
We have around 40-50 Azure subscriptions. A resource group should be deployed to each of the subscription. In each resource group backup vault and policies etc will furthermore added deployed (some of the vault are in different region deployed). To not repeat code, if created a module which runs in an for_each loop (in the module there is an other for_each loop for the vault/policies etc). The terraform code runs so far correct, with the limit that all resource groups are deployed in the same subscription.
Attempted Solutions
To bring more dynamic in to the code i've tried to add the resource provider in to the module and then add the right subscription id trough an variable to the module. terraform does not allow this procedure. Even if i add 40 resource provider in an provider.tf file i'm not able to change the subscription for each iteration of the module.
This is a big limitation to terraform.
Proposal
Make a more dynamic way of given an provider as input to an resource. The resources will be implemented by an module in an for_each loop. Would even love to have an more dynamic way to change subscription than creating 40 resource provider with aliases.
References
https://www.terraform.io/language/modules/develop/providers
The text was updated successfully, but these errors were encountered: