← Building the platform

Chapter 5 · Landing zone

Landing Zone: azure-rafaelsonego-lz-infra

Azure Entra ID Terraform Azure DevOps

What it is

This is the repo that everything else in the platform stands on. One Terraform root, rafaelsonego-sub/landing-zone, covers the whole subscription across both regions (Canada Central and Canada East) and owns:

  • the management group the subscription sits under;
  • the resource groups for each workload (shared, rafaelsonego per region, corenetwork, log-analytics, mgmt);
  • every pipeline service principal's identity, its role assignments and its federated credential;
  • the custom RBAC roles those assignments use;
  • the core VNet, the private DNS zones and the shared Log Analytics workspace;
  • cost budgets and their alerts;
  • the Entra app registration this website signs in with, including its App Roles and API permissions.

Workload repos then build inside the resource groups this repo hands them, each with its own pipeline identity.

Why it exists

The idea is one landing zone repo per subscription. rafaelsonego is a subscription, so everything that belongs to the subscription as a whole is defined here: a new resource group in Canada Central or Canada East, a service principal, a role. The shared pieces live here too: the corenetwork resource group with the VNets and their address space, and the log-analytics resource group with the workspace.

A workload doesn't get the subscription. It gets a resource group and a service principal that can work only inside it. Today there are two workloads: shared-infra and rafaelsonego-infra. Each one's service principal has Contributor on its own resource group, minus the right to delete it. So the line is simple: if it's about who gets access to what, or something more than one workload depends on, it's landing zone. If it lives inside one workload's resource group, it's workload infra.

Key decisions

  • App registration creation is lz-infra-only. Workload infra repos (like azure-rafaelsonego-infra) run under service principals that only hold Azure RBAC roles — no Microsoft Graph permissions — so they can't create azuread_application/azuread_service_principal resources themselves. Any new Entra app registration a workload needs gets created here instead, and the resulting client ID is read from this repo's state and copied into the workload repo.
  • No pipeline holds a secret. Every Terraform pipeline authenticates through an Azure DevOps service connection that uses workload identity federation (OIDC). The only catch is ordering: ADO generates the federation subject when the connection is created, so a new identity takes four steps. Create the service principal here, create the service connection in the ADO repo, add the federated credential here with the real subject, then use it.
  • One service principal per workload and region. Each one owns exactly one resource group. When Canada East was added for Azure OpenAI (the model quota only existed there), it got its own resource group, its own service principal and its own pipeline instead of widening the Canada Central one.
  • Pipelines can manage access, but can't escalate. Workload service principals hold a custom contributor-no-rg-delete role: Contributor without resource-group deletion, plus data-plane access and the right to create role assignments, so they can grant their own apps access without me doing it by hand. An ABAC condition on the assignment blocks them from granting Owner, User Access Administrator or RBAC Administrator.
  • Reading across regions is a named, read-only role. When one region's Terraform needs to look up the other's resources, it gets a custom cross-rg-reader role: */read and nothing else. No list actions, because those return secrets. Listing a web app's settings, for example, returns the key that signs its session cookies.
  • Every workload pipeline can read the whole subscription. Once the pipelines started drawing what they deploy, they needed to look at what their resources point to in other groups: the shared network, the Log Analytics workspace. A subscription_reader flag on a service principal gives it the built-in Reader role at subscription scope. It's the same */read rule as above, so seeing more still doesn't mean reaching a single secret or changing anything.

Current state

Live and applied through its own pipeline, built on the same shared Terraform template as the workload repos. It manages six service principals (five of them pipeline identities, all secretless), six resource groups across two regions, the custom roles the workload pipelines use, and the one app registration. The only service principal with a stored secret is the read-only Grafana one, since Grafana Cloud runs outside Azure and can't use federation.