Skip to content

Commit

Permalink
add system topics
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirkamara committed Jan 7, 2025
1 parent 49a2b02 commit ada8d70
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
6 changes: 5 additions & 1 deletion core/terraform/airlock/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ data "azurerm_container_registry" "mgmt_acr" {
resource_group_name = var.mgmt_resource_group_name
}

data "azurerm_monitor_diagnostic_categories" "eventgrid" {
data "azurerm_monitor_diagnostic_categories" "eventgrid_custom_topics" {
resource_id = azurerm_eventgrid_topic.airlock_notification.id
}

data "azurerm_monitor_diagnostic_categories" "eventgrid_system_topics" {
resource_id = azurerm_eventgrid_system_topic.export_approved_blob_created.id
}
27 changes: 25 additions & 2 deletions core/terraform/airlock/eventgrid_topics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ resource "azurerm_eventgrid_event_subscription" "export_approved_blob_created" {
]
}

resource "azurerm_monitor_diagnostic_setting" "eventgrid" {
resource "azurerm_monitor_diagnostic_setting" "eventgrid_custom_topics" {
for_each = merge({
(azurerm_eventgrid_topic.airlock_notification.name) = azurerm_eventgrid_topic.airlock_notification.id,
(azurerm_eventgrid_topic.step_result.name) = azurerm_eventgrid_topic.step_result.id,
Expand All @@ -520,7 +520,30 @@ resource "azurerm_monitor_diagnostic_setting" "eventgrid" {
target_resource_id = each.value
log_analytics_workspace_id = var.log_analytics_workspace_id
dynamic "enabled_log" {
for_each = data.azurerm_monitor_diagnostic_categories.eventgrid.log_category_types
for_each = data.azurerm_monitor_diagnostic_categories.eventgrid_custom_topics.log_category_types
content {
category = enabled_log.value
}
}

metric {
category = "AllMetrics"
}
}

resource "azurerm_monitor_diagnostic_setting" "eventgrid_system_topics" {
for_each = {
(azurerm_eventgrid_system_topic.import_inprogress_blob_created.name) = azurerm_eventgrid_system_topic.import_inprogress_blob_created.id,
(azurerm_eventgrid_system_topic.import_rejected_blob_created.name) = azurerm_eventgrid_system_topic.import_rejected_blob_created.id,
(azurerm_eventgrid_system_topic.import_blocked_blob_created.name) = azurerm_eventgrid_system_topic.import_blocked_blob_created.id,
(azurerm_eventgrid_system_topic.export_approved_blob_created.name) = azurerm_eventgrid_system_topic.export_approved_blob_created.id,
}

name = "${each.key}-diagnostics"
target_resource_id = each.value
log_analytics_workspace_id = var.log_analytics_workspace_id
dynamic "enabled_log" {
for_each = data.azurerm_monitor_diagnostic_categories.eventgrid_system_topics.log_category_types
content {
category = enabled_log.value
}
Expand Down
4 changes: 2 additions & 2 deletions core/terraform/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ set -o nounset
# This is where we can migrate any Terraform before we plan and apply
# For instance deprecated Terraform resources
# shellcheck disable=SC1091
source ./migrate.sh
# source ./migrate.sh

PLAN_FILE="tfplan$$"
TS=$(date +"%s")
PLAN_FILE="${TS}-tre-core.tfplan"
LOG_FILE="${TS}-tre-core.log"

# This variables are loaded in for us
Expand Down

0 comments on commit ada8d70

Please sign in to comment.