Terraform foreach multiple map variables
Is something like the below what you are looking for?
locals {
  apps = keys(var.app_config)
}

resource &quot;azurerm_key_vault_secret&quot; &quot;app_id&quot; {
  for_each = toset(local.apps)

  name         = each.key
  value        = var.keyvault_secrets[var.environment][each.key][&quot;application_id&quot;]
  key_vault_id = data.azurerm_key_vault.mykv.id
}