Skip to content

Architecture

The parts of the platform and how they fit: the repositories, how a customer repository consumes the engine, where the runners sit, and how identity and state are held. Read it once before setup; it explains why the setup steps come in the order they do.

The repositories

The platform is one shared engine and a per-customer landing-zone repository, with supporting repositories and a license service under NRIT control.

Repository Role
PR-ops engine (nrit-tfpr, called through the public tfpr entrypoint) The shared automation: the compiled tfpr engine binary, driven by GitHub Actions reusable workflows and a composite action, that plans, applies, detects drift, and runs the gates. Customer repos call the public entrypoint at a pinned tag, and the jobs install the engine runtime from that tag's public release. They do not copy it.
Landing-zone repository A per-customer Terragrunt monorepo. It holds the actual Azure landing zone under live/, five thin caller workflows that invoke the engine, and a projects.yml that tells the engine what to discover, which paths to exempt from the merge gate, and which gates to run. nrit-alz-customer-template is the template the bootstrap generates new customer repos from; nrit-alz-live is NRIT's own production repository, generated from the same template, and serves as the reference implementation.

These sit behind them:

  • nrit-alz-bootstrap provisions everything a landing-zone repo needs: the state storage account (blob state and the unit-lock table, with the role assignments for both), the plan and apply OIDC identities and their federated credentials, the plan and apply environments, the customer repository generated from the template with its variables and secrets, the branch ruleset, and the self-hosted runner. See Bootstrap a customer.
  • nrit-alz-runner-image builds and signs the runner image once for every customer. The bootstrap imports it by digest. See Self-hosted runner and the GitHub Apps.
  • The license service at license.nrit.cloud issues licenses and entitlements and publishes the signed revocation list that every engine job checks. See License.

Platform architecture: the landing-zone repo calls the tfpr engine at a pinned tag; the engine signs in to the customer Azure tenant with OIDC, where a self-hosted runner plans and applies the landing zone and reads and writes Terraform state; the engine checks the license service and the runner fetches modules from the public AVM registryPlatform architecture: the landing-zone repo calls the tfpr engine at a pinned tag; the engine signs in to the customer Azure tenant with OIDC, where a self-hosted runner plans and applies the landing zone and reads and writes Terraform state; the engine checks the license service and the runner fetches modules from the public AVM registry

How the engine is consumed

The customer repo carries five thin caller workflows, all pinned to the same engine release. Two call the engine's reusable workflows (comment commands and the drift sweep); three call the engine's dispatch composite action (the pull request path, the unlock on close, and the review refresh). Each carries one pin, its uses: ref. At run time each job installs the engine runtime of that release from the public entrypoint repository: the tfpr binary, and the gate scripts in .tfpr-engine, exposed to hooks as $TFPR_ENGINE_DIR. No engine credential is involved. tfpr apply also needs a license; see License. So the customer repo holds only its own Terraform and the five callers; the engine is never copied in. The current pins are on Versions and upgrades; the mechanics are on The PR-ops engine.

Runner topology

Jobs run on one of two runner types, chosen per job.

  • Hosted runners (ubuntu-latest) run the jobs that hold no Azure identity: discovery of the PR's units, resolving the event, setting the merge gate, and reporting drift issues.
  • Self-hosted runners run every job that touches Azure: plan, apply, the drift plan, the unlock, and the drift run's lock sweep. They sit on a private network with access to the state account behind its firewall. The runner label is set with the RUNNER_LABEL variable, and jobs fall back to ubuntu-latest when it is not set (useful for demos).

The runner image, the tools it bakes in, and the sizing the bootstrap applies (and why the AVM defaults are too small for ALZ policy plans) are covered in Self-hosted runner and the GitHub Apps.

Identity and state

  • Azure access is Entra workload-identity OIDC. Two GitHub environments, plan and apply, each bind a federated credential. The plan identity is Reader at the management group scope and Storage Blob Data Contributor on the state container, which terraform init needs to create the state blob of a unit that has never been applied. The apply identity is Owner at the management group scope and Storage Blob Data Contributor on the state container. Both can use the unit-lock table. There is no cloud secret in the repo.
  • Only the Azure jobs request a token. The jobs that read PR code or decide (discover, resolve, gate, drift's report, and the PR caller's dispatch) never request an id-token. Discovery of the PR's HCL runs in its own job with no environment and a read-only token. The Azure jobs (the plan matrix, apply, unlock, drift-plan, and the lock sweep) run under the plan or apply environment and request the token there. This split keeps PR-branch code away from write credentials.
  • The OIDC subject uses immutable repository ids. GitHub renders the sub claim of newly created repos as repo:org@id/repo@id:environment:env. The bootstrap builds the federated credential subjects in that format by default (oidc_subject_uses_repo_ids), and only falls back to the legacy name-only form for repos created before that rollout.
  • State lives in an Azure storage account in the management subscription, with Entra ID auth (no account keys). On the self_hosted_private posture a firewall allows only the runner's egress address; on the GitHub-hosted posture Entra auth is the only control. Terragrunt writes each unit's state to a key derived from the unit path.

The Security model page covers the identities, the trust split, and the gates in one place.

The landing zone

The reference landing zone follows the Cloud Adoption Framework layout under live/:

  • A _foundation/ tree that is deployed first and creates the management group hierarchy, base policy, management resources (Log Analytics, monitoring), and the Azure Monitor Baseline Alerts.
  • A platform/ tree for connectivity (hub network) and other platform subscriptions.
  • A landingzones/ tree for workload subscriptions (for example a corp landing zone with its spoke network and workloads).

Every unit is plain Terraform: a main.tf sourcing a public Azure Verified Module at a pinned version, beside a thin terragrunt.hcl. The custom Azure Policy library is vendored into the repository at live/_foundation/landing-zones/lib/ and layered over the stock ALZ library. See Live tree for the full layout.

The same path, from a bootstrap-generated repo to a first applied plan, is what NRIT runs on its own tenant. NRIT's own landing-zone repository is generated from the same template and calls the same engine release as a customer repo, so the platform is exercised in production before it is handed over.

Read on: How it works.