# TFNFR12 - Dynamic for Optional Nested Objects Module Specification for the Azure Verified Modules (AVM) program ID: TFNFR12 - Category: Code Style - Dynamic for Optional Nested Objects An example from the community: resource "azurerm_kubernetes_cluster" "main" { ... dynamic "identity" { for_each = var.client_id == "" || var.client_secret == "" ? [1] : [] content { type = var.identity_type user_assigned_identity_id = var.user_assigned_identity_id } } ... } Please refer to the coding style in the example. Nested blocks under conditions, MUST be declared as: for_each = <condition> ? [<some_item>] : [] --- Source: https://raw.githubusercontent.com/Azure/Azure-Verified-Modules/refs/heads/main/docs/content/specs-defs/includes/terraform/shared/non-functional/TFNFR12.md Last Modified: 0001-01-01