|
| 1 | +module "log_analytics_workspace_hub" { |
| 2 | + for_each = var.regions |
| 3 | + |
| 4 | + source = "../../../../dtos-devops-templates/infrastructure/modules/log-analytics-workspace" |
| 5 | + |
| 6 | + name = module.config[each.key].names.log-analytics-workspace |
| 7 | + resource_group_name = azurerm_resource_group.rg_base[each.key].name |
| 8 | + location = each.key |
| 9 | + |
| 10 | + law_sku = var.law.law_sku |
| 11 | + retention_days = var.law.retention_days |
| 12 | + |
| 13 | + monitor_diagnostic_setting_log_analytics_workspace_enabled_logs = local.monitor_diagnostic_setting_log_analytics_workspace_enabled_logs |
| 14 | + monitor_diagnostic_setting_log_analytics_workspace_metrics = local.monitor_diagnostic_setting_log_analytics_workspace_metrics |
| 15 | + |
| 16 | + tags = var.tags |
| 17 | +} |
| 18 | + |
| 19 | +# Add a data export rule to forward logs to the Event Hub in the Hub subscription |
| 20 | +module "log_analytics_data_export_rule" { |
| 21 | + for_each = var.features.log_analytics_data_export_rule_enabled ? var.regions : {} |
| 22 | + |
| 23 | + source = "../../../../dtos-devops-templates/infrastructure/modules/log-analytics-data-export-rule" |
| 24 | + |
| 25 | + name = "${module.config[each.key].names.log-analytics-workspace}-export-rule" |
| 26 | + resource_group_name = azurerm_resource_group.rg_base[each.key].name |
| 27 | + workspace_resource_id = module.log_analytics_workspace_hub[each.key].id |
| 28 | + destination_resource_id = module.eventhub_law_export["dtos-hub-${each.key}"].event_hubs["dtos-hub"].id |
| 29 | + table_names = var.law.export_table_names |
| 30 | + enabled = var.law.export_enabled |
| 31 | +} |
| 32 | + |
| 33 | +/*-------------------------------------------------------------------------------------------------- |
| 34 | + RBAC Assignments |
| 35 | +--------------------------------------------------------------------------------------------------*/ |
| 36 | +/* |
| 37 | +For sending events to the Event Hub: |
| 38 | +* Azure Event Hubs Data Sender: Grants permissions to send events to the Event Hub. |
| 39 | +* For receiving events from the Event Hub: |
| 40 | +
|
| 41 | +For receiving events from the Event Hub (i.e. remote resource): |
| 42 | +* Azure Event Hubs Data Receiver: Grants permissions to receive events from the Event Hub. |
| 43 | +*/ |
| 44 | +# module "rbac_assignments" { |
| 45 | +# for_each = var.regions |
| 46 | + |
| 47 | +# source = "../../../dtos-devops-templates/infrastructure/modules/rbac-assignment" |
| 48 | + |
| 49 | +# principal_id = module.log_analytics_workspace_audit[each.key].0.principal_id |
| 50 | +# role_definition_name = "Azure Event Hubs Data Sender" |
| 51 | +# scope = data.terraform_remote_state.hub.outputs.eventhub_law_export_id["dtos-hub-${each.key}"] |
| 52 | +# } |
0 commit comments