79333008

Date: 2025-01-06 12:28:16
Score: 1
Natty:
Report link

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=-

.

Reasons:
  • Blacklisted phrase (1): Cheers
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Andrew Haigh