Configures KeyVault to log to a log analytics workspace
This commit is contained in:
@@ -76,4 +76,26 @@ resource "azurerm_key_vault_access_policy" "keyvault_admin_policy" {
|
||||
"backup",
|
||||
"update",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_monitor_diagnostic_setting" "keyvault_diagnostic" {
|
||||
name = "${var.name}-${var.environment}-keyvault-diag"
|
||||
target_resource_id = azurerm_key_vault.keyvault.id
|
||||
log_analytics_workspace_id = var.workspace_id
|
||||
|
||||
log {
|
||||
category = "AuditEvent"
|
||||
enabled = true
|
||||
|
||||
retention_policy {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
metric {
|
||||
category = "AllMetrics"
|
||||
|
||||
retention_policy {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -48,4 +48,10 @@ variable "whitelist" {
|
||||
type = map
|
||||
description = "A map of whitelisted IPs and CIDR ranges. For single IPs, Azure expects just the IP, NOT a /32."
|
||||
default = {}
|
||||
}
|
||||
}
|
||||
|
||||
variable "workspace_id" {
|
||||
description = "Log Analytics Workspace ID for sending logs generated by this resource"
|
||||
type = string
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user