Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource Provider configuration in Modules with for_each loops #30676

Closed
chrisfromzurigo opened this issue Mar 15, 2022 · 2 comments
Closed

Resource Provider configuration in Modules with for_each loops #30676

chrisfromzurigo opened this issue Mar 15, 2022 · 2 comments

Comments

@chrisfromzurigo
Copy link

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

@chrisfromzurigo chrisfromzurigo added enhancement new new issue not yet triaged labels Mar 15, 2022
@jbardin
Copy link
Member

jbardin commented Mar 15, 2022

Hi @chrisfromzurigo,

You can follow the existing enhancement request in #25244, and also see the related request in #19932.

Thanks!

@jbardin jbardin closed this as completed Mar 15, 2022
@crw crw removed the new new issue not yet triaged label Mar 16, 2022
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants