-
Notifications
You must be signed in to change notification settings - Fork 0
/
diagnostics.tf
36 lines (30 loc) · 1.32 KB
/
diagnostics.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
###################
### Diagnostics ###
###################
# Manages a Diagnostic Setting for an existing Resource.
#
# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting
#
resource "azurerm_monitor_diagnostic_setting" "postgresql_server" {
count = (var.diagnostics != null) ? 1 : 0
name = "${var.name}-pgsql-diag"
target_resource_id = azurerm_postgresql_flexible_server.pgsql.id
log_analytics_workspace_id = local.parsed_diag.log_analytics_id
eventhub_authorization_rule_id = local.parsed_diag.event_hub_auth_id
eventhub_name = local.parsed_diag.event_hub_auth_id != null ? var.diagnostics.eventhub_name : null
storage_account_id = local.parsed_diag.storage_account_id
dynamic "log" {
for_each = data.azurerm_monitor_diagnostic_categories.postgresql_server[0].logs
content {
category = log.value
enabled = contains(local.parsed_diag.log, "all") || contains(local.parsed_diag.log, log.value)
}
}
dynamic "metric" {
for_each = data.azurerm_monitor_diagnostic_categories.postgresql_server[0].metrics
content {
category = metric.value
enabled = contains(local.parsed_diag.metric, "all") || contains(local.parsed_diag.metric, metric.value)
}
}
}