Migrating diagnostic settings for a set of Terraform stacks between Azure regions, one environment at a time
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.
terraform init. I reverted it quickly and re-landed it with each pipeline on a source it could authenticate to.replace() local, rather than a risky module upgrade in the same change.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" }
}
log_analytics_destination_type), fixed with the provider's opt-out flag.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.
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.