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.
// 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
- Triggerpush to main (path filtered), weekly cron or manual dispatch
- Keyless authOIDC login to Azure and Google via workload identity federation
- Static checksfmt, init, validate, lint and scan
- Planhigher parallelism for read waves; exit code interpreted
- Branch on result gate0 no change, 1 fail, 2 changes
- Reportmarkdown summary, plan artifacts, colour-coded chat message
- Approval gateapply bound to a protected environment
- Applythe exact saved plan, with lower parallelism for writes
- 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.