← Back to Projects

Moving Central Logging to a New Region

Migrating diagnostic settings for a set of Terraform stacks between Azure regions, one environment at a time

Platform: Azure Monitor
IaC: Terraform (multi-stack)
Approach: Environment-by-environment
Role: Change owner

Overview

Diagnostic settings across a set of platform Terraform stacks (messaging, cache, security, edge, data and others) sent logs to workspaces in a different region from the workloads. I moved them to workspaces in the workload region, applying and verifying one environment at a time, and without forcing changes onto resources that had drifted outside Terraform.

Plan

Devapply + verifyTestapply + verifyPre-prodapply + verifyUATProdchange request
Rollout order, with a gate before production

Implementation

  1. First attempt, reverted. The PR mixed module sources that needed different credentials, and pipelines holding only one of them failed at terraform init. I reverted it quickly and re-landed it with each pipeline on a source it could authenticate to.
  2. Stacks on older modules got the new workspace ID through a small replace() local, rather than a risky module upgrade in the same change.
  3. Each environment: plan review, apply, then confirm logs were actually arriving in the new workspace.
  4. Drift held back. One edge stack carried unrelated drift, so I ran it plan-only and handed it to its owner instead of applying over their changes.
diagnostics (illustrative)
locals {
  law_id_target = replace(var.log_analytics_workspace_id, "-regiona-", "-regionb-")
}

resource "azurerm_monitor_diagnostic_setting" "this" {
  name                       = "diag-central"
  target_resource_id         = azurerm_redis_cache.this.id
  log_analytics_workspace_id = local.law_id_target
  enabled_log { category_group = "allLogs" }
}

Things I Found Along the Way

Key Outcomes

Lessons Learned

Conclusion

A wide, low-risk change is still a wide change. Rolling out one environment at a time and verifying each step made it boring, which is the goal.

Technologies Used

TerraformAzure Monitor Diagnostic SettingsLog AnalyticsData Collection RulesAzure DevOpsGitHub EnterpriseRedisService BusFront Door

About this case study: this write-up is drawn from my hands-on platform engineering experience. Organisation names, system names, figures and timelines have been changed or generalised, and all code, configuration and queries are illustrative examples written for this page.

← Observability: Noise, Gaps and Blind SpotsManaged SQL as Code, Safely →
← Back to Projects Get in Touch