# A key works for whoever has it, and Microsoft documents no caller identity # for a call signed with one. The built-in policy "Azure AI Services # resources should have key access disabled (disable local authentication)" # flags every Cognitive Services account in the subscription that still # accepts keys. It also flags Azure AI Search services that do. # # Audit reports those accounts under Policy, Compliance. Deny also refuses a # new or changed account that leaves keys on, with 403 Forbidden; accounts # that already have keys on are reported and left running. After keys are # turned off on an account, Azure can keep accepting the old ones for up to # several hours, until its cache refreshes. # # The policy's own description warns that Azure OpenAI Studio needs key # access. Try Deny on a test subscription first. resource "azurerm_subscription_policy_assignment" "key_access" { name = "ai-key-access-disabled" subscription_id = "/subscriptions/${var.subscription_id}" policy_definition_id = "/providers/Microsoft.Authorization/policyDefinitions/71ef260a-8f18-47b7-abcb-62d0673d94dc" display_name = "Azure AI Services resources should have key access disabled (disable local authentication)" description = "Assigned by ai-model-logging. A key works for whoever has it, and Microsoft documents no caller identity for a call signed with one." parameters = jsonencode({ effect = { value = var.key_access_policy_effect } }) }