Reputation: 91
I would like to create multiple azure_rm providers, from a variable list. Trying with "count" is not possible, I got the message "reserved for future usage".
Technicaly describing, the section that I would like to dynamic create is:
provider "azurerm" {
features {}
subscription_id = "1d1a56ed-681f-xxxx-xxxx-xxxxxxxxxxxx"
alias = "spoke1"
}
I tried also with for_each, but also not possible, since for_each creates only a section, not a complete "provider" section.
# To improve... try to use dynamic block
# It looks to be not possible. Could be necessary to auto-generate this scetion with external script
# provider "azurerm" {
# features {}
# dynamic "spoke" {
# for_each = var.spoke_networks
# content {
# subscription_id = spoke.value["subscription_id"]
# alias = spoke.value["subscription_alias"]
# }
# }
# }
What I would like to achieve is to just feed my variable(spoke_networks) with a new entry, and terraform creates a new provider. the variable file stucture should be something like this:
variable "spoke_networks" {
description = "List with the properties of the Spoke VNETs"
type = list(object({subscription_alias=string ,subscription_id=string , resource_group_name=string , vnet_name=string }))
}
Thank you, VS
Upvotes: 1
Views: 676
Reputation: 238209
You can't do this with terraform
. But possibly you could do it with terragrunt.
Upvotes: 1