Identity & Access · Performance

Making a 2,000-Member Identity Plan Fast, Safe and Authoritative

A pipeline that plans on every push and weekly, applies only real changes behind a gate, and reads membership in bulk instead of per resource.

  • GitHub Actions
  • Terraform external data source
  • bash
  • jq
  • Microsoft Graph $batch
  • PIM APIs
  • Checkov
  • TFLint

// Overview

The group workflow runs on push, on a weekly schedule (plan-only drift check) and on manual dispatch. Membership is read via bulk data sources and Graph batch calls and reconciled imperatively instead of as thousands of per-member resources. A bash script used as a Terraform external data source reads PIM eligibility in batches with pagination and retry on throttling.

// The problem

Per-member resources made refresh extremely slow and brittle, so scheduled drift detection was impractical.

// Flow

Making a 2,000-Member Identity Plan Fast, Safe and Authoritative flow1. Trigger → 2. Keyless auth → 3. Static checks → 4. Plan → 5. Branch on result → 6. Report → 7. Approval gate → 8. Apply → 9. Notify01Trigger02Keyless auth03Static checks04Plan05 · GATEBranch on result06Report07Approval gate08Apply09Notify
  1. Triggerpush to main (path filtered), weekly cron or manual dispatch
  2. Keyless authOIDC login to Azure and Google via workload identity federation
  3. Static checksfmt, init, validate, lint and scan
  4. Planhigher parallelism for read waves; exit code interpreted
  5. Branch on result gate0 no change, 1 fail, 2 changes
  6. Reportmarkdown summary, plan artifacts, colour-coded chat message
  7. Approval gateapply bound to a protected environment
  8. Applythe exact saved plan, with lower parallelism for writes
  9. Notifysuccess or failure message

// Design decisions & guardrails

  • Concurrency group with cancel-in-progress off, so runs queue and never abort mid-apply.
  • PIM membership handling is add-only: it never revokes high-tier eligibility, and a miss costs only a redundant add next run.
  • Members who activated eligibility are ignored via lifecycle rules so activation is not undone.
  • Pagination follows next-links to exhaustion; transient errors retry up to five times with backoff.
  • Runs on a network-close self-hosted runner pool for API latency.

// Outcome

About 2,300 per-member resources replaced by bulk reads; batches of 20 per Graph call; weekly drift check.

// Related