【问题标题】:Enabling Activity Logs Diagnostic Settings using Terraform使用 Terraform 启用活动日志诊断设置
【发布时间】:2021-07-26 16:49:22
【问题描述】:

目前有一个模块可以为链接here 的 Azure 资源创建日志诊断设置。使用该门户,我能够为活动日志生成日志诊断设置以及提到的here。我试图启用活动日志诊断设置并将日志发送到存储帐户,但只遇到了这个module

但是,似乎无法使用此模块将活动日志发送到日志分析工作区。它也不支持门户中提到的日志类别(即AdministrativeSecurityServiceHealth 等),仅提供ActionDeleteWrite。这使我相信它们不打算用于相同的目的。第一个模块需要target_resource_id,并且由于订阅级别中存在活动日志,因此不存在此类 ID。

因此,是否可以使用第一个提到的模块或完全不同的模块来启用诊断设置?任何有关此事的帮助将不胜感激

【问题讨论】:

    标签: azure terraform azure-rm


    【解决方案1】:

    您可以通过将订阅 ID 指定为 azurerm_monitor_diagnostic_setting 资源中的 target_resource_id 来进行配置。

    例子:

    resource "azurerm_monitor_diagnostic_setting" "example" {
        name                           = "example"
        target_resource_id             = "/subscriptions/85306735-db49-41be-b899-b0fc48095b01"
    
        eventhub_name = azurerm_eventhub.diagnostics.name
        eventhub_authorization_rule_id = azurerm_eventhub_namespace_authorization_rule.diagnostics.id
    
        log {
            category = "Administrative"
    
            retention_policy {
            enabled = false
        }
    }
    

    【讨论】:

      【解决方案2】:

      您应该使用属性“log_analytics_workspace_id”

      resource "azurerm_monitor_diagnostic_setting" "example" {
      name                           = "example"
      target_resource_id             = "/subscriptions/xxxx"
      
      log_analytics_workspace_id     = azurerm_log_analytics_workspace.this.id
      log_analytics_destination_type = "Dedicated" # or null see [documentation][1]
      
      log {
          category = "Administrative"
      
          retention_policy {
          enabled = false
        }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-03-21
        • 2017-06-04
        • 1970-01-01
        • 1970-01-01
        • 2020-03-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多