It is possible to combine "count" and "for_each" in a terraform resource block
But you have to be "dynamic" about it
Here's an example of what I have in place (and working)
resource "azurerm_network_security_group" "nsg-001" {
count = var.nsg-deploy.deploy ? 1 : 0
dynamic "security_rule" {
for_each = local.nsg_001_ruleset_001
content {}
}
Cheers
-=A=-
.