Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
frasdav committed May 31, 2024
1 parent 77d6303 commit d3541b0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
30 changes: 29 additions & 1 deletion modules/cdn-profile/src/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,32 @@ resource "azurerm_cdn_profile" "main" {
tags = merge(var.tags, local.tags)
}

// TODO: Diag settings?
resource "azurerm_monitor_diagnostic_setting" "main" {
name = "log-analytics"
target_resource_id = azurerm_cdn_profile.main.id
log_analytics_workspace_id = var.log_analytics_workspace_id

dynamic "enabled_log" {
for_each = var.log_categories

content {
category = enabled_log.value
}
}

dynamic "enabled_log" {
for_each = var.log_category_groups

content {
category_group = enabled_log.value
}
}

dynamic "metric" {
for_each = var.metric_categories

content {
category = metric.value
}
}
}
24 changes: 24 additions & 0 deletions modules/cdn-profile/src/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ variable "identifier" {
type = string
}

variable "log_analytics_workspace_id" {
type = string
}

# https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-logs/microsoft-cdn-profiles-logs
variable "log_categories" {
type = list(string)
default = []
}

variable "log_category_groups" {
type = list(string)
default = [
"audit",
]
}

variable "metric_categories" {
type = list(string)
default = [
"AllMetrics",
]
}

variable "resource_group_name" {
type = string
}
Expand Down
2 changes: 2 additions & 0 deletions modules/cdn-profile/test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module "cdn_profile" {
resource_group_name = "qux"
zone = "baz"

log_analytics_workspace_id = "quux"

tags = {
Foo = "Bar"
}
Expand Down

0 comments on commit d3541b0

Please sign in to comment.