I'm trying to create a set of subnet rules for a cosmosdb account.
I've tried a dynamic and a for_each on the resource and I get the same error each time - am I going about this the wrong way?
Currently trying this:
resource "azurerm_cosmosdb_account" "db" {
name = local.name
location = var.location
resource_group_name = var.resource_group_name
offer_type = "Standard" #(Required) Specifies the Offer Type to use for this CosmosDB Account - currently this can only be set to Standard.
enable_free_tier = var.enable_free_tier
kind = var.kind
identity {
type = "SystemAssigned"
}
ip_range_filter = join(",", local.network_rules.ip_rules)
dynamic "virtual_network_rule" {
for_each = var.virtual_network_subnet_ids
content {
id = each.value
}
}
}
Currently getting:
Error: each.value cannot be used in this context
│
│ on .terraform/modules/azurerm_cosmosdb_account/azurerm_cosmosdb_account/main.tf line 27, in resource "azurerm_cosmosdb_account" "db":
│ 27: id = each.value
│
│ A reference to "each.value" has been used in a context in which it
│ unavailable, such as when the configuration no longer contains the value in
│ its "for_each" expression. Remove this reference to each.value in your
│ configuration to work around this error.
╵