Skip to content

libre-devops/terraform-azurerm-diagnostic-settings

Repository files navigation

resource "azurerm_monitor_diagnostic_setting" "diagnostic_settings" {
  count = var.diagnostic_settings != null ? 1 : 0

  name                           = local.diagnostic_setting_name
  target_resource_id             = var.diagnostic_settings.target_resource_id
  storage_account_id             = try(var.diagnostic_settings.storage_account_id, null)
  eventhub_name                  = try(var.diagnostic_settings.eventhub_name, null)
  eventhub_authorization_rule_id = try(var.diagnostic_settings.eventhub_authorization_rule_id, null)
  log_analytics_workspace_id     = try(var.diagnostic_settings.law_id, null)
  log_analytics_destination_type = try(var.diagnostic_settings.law_destination_type, null)
  partner_solution_id            = try(var.diagnostic_settings.partner_solution_id, null)

  dynamic "enabled_log" {
    for_each = local.adjusted_enabled_log != [] ? toset(local.adjusted_enabled_log) : []
    content {
      category       = enabled_log.value.category
      category_group = try(enabled_log.value.category_group, null)
    }
  }

  dynamic "metric" {
    for_each = local.adjusted_metric != [] ? toset(local.adjusted_metric) : []
    content {
      category = metric.value.category
      enabled  = metric.value.enabled
    }
  }
}

Requirements

No requirements.

Providers

Name Version
azurerm n/a

Modules

No modules.

Resources

Name Type
azurerm_monitor_diagnostic_setting.diagnostic_settings resource

Inputs

Name Description Type Default Required
diagnostic_settings An object containing the diagnostic settings for a resource
object({
diagnostic_settings_name = optional(string)
target_resource_id = string
storage_account_id = optional(string)
eventhub_name = optional(string)
eventhub_authorization_rule_id = optional(string)
law_id = optional(string)
law_destination_type = optional(string, "Dedicated")
partner_solution_id = optional(string)
enabled_log = optional(list(object({
category = optional(string)
category_group = optional(string)
})), [])
metric = optional(list(object({
category = string
enabled = optional(bool, true)
})), [])
enable_all_logs = optional(bool, false)
enable_all_metrics = optional(bool, false)
})
n/a yes

Outputs

Name Description
diagnostic_setting_id The ID of the diagnostic setting.
diagnostic_setting_name The name of the diagnostic setting.
eventhub_name The name of the Event Hub associated with the diagnostic setting.
log_analytics_workspace_id The ID of the log analytics workspace associated with the diagnostic setting.
storage_account_id The ID of the storage account associated with the diagnostic setting.
target_resource_id The ID of the resource targeted by the diagnostic setting.

About

A module used to deploy diagnostic settings 🕵️‍♂️

Resources

License

Stars

Watchers

Forks

Packages

No packages published