Guides · AI & DevOps · ai-agents · terraform · kubernetes
Using Parallel AI Agents for Infrastructure Migrations
· 5 min read
Parallel AI agents are genuinely useful for one category of infrastructure work: wide, shallow migrations. Terraform provider upgrades across 30 modules, Kubernetes API deprecation sweeps, base-image bumps across every Dockerfile — chores where each unit of work is small, repetitive, and independently reviewable. The pattern that works is fan-out with hard review gates: agents propose changes in parallel, humans and CI review serially, and nothing merges — let alone applies — without a gate. Agents parallelize the typing; they don’t parallelize the judgment.
Which infrastructure chores actually parallelize well?
The good candidates share a shape: many independent files, one mechanical transformation, and a cheap way to verify each result. If a task needs cross-cutting judgment or touches shared state, parallelism hurts more than it helps.
| Chore | Parallelizes? | Verification gate |
|---|---|---|
| Terraform provider major upgrades across modules | Yes — one agent per module group | terraform plan diff per module |
| K8s API deprecation sweeps across manifests/charts | Yes — one agent per app or chart | kubectl apply --dry-run, kubeconform in CI |
| Base-image bumps across Dockerfiles | Yes — one agent per service | Image builds + test suite |
| Renaming a shared module everything imports | No — do it once, centrally | Single reviewed PR |
| Changing networking/state that resources depend on | No — sequencing matters | Human-planned runbook |
Concrete examples: the AWS provider 6.0 release (June 2025, per HashiCorp’s announcement) moved multi-region support into a single provider configuration with a region attribute on resources — a breaking change that touches every multi-region module in roughly the same way. Similarly, Kubernetes removed flowcontrol.apiserver.k8s.io/v1beta3 in v1.32 per the upstream deprecation guide, and every removal wave before it followed the same find-and-migrate pattern across manifests. Both are textbook fan-out work. Compare tools for this in our AI coding tools roundup.
How do you structure the fan-out?
Shard by blast radius, isolate each agent’s workspace, and restrict each agent’s tools. In Claude Code, for example, subagents run in their own context windows, can be pinned to an allowlist of tools in a config file, and support isolation: worktree so each one works in its own git worktree, with a documented cap on how many run concurrently. Other agent runners can replicate the same shape with plain git worktrees and separate branches.
The workflow that holds up in practice:
- Inventory first. One pass to list every module, chart, or Dockerfile in scope, then shard into groups of 5–10 units per agent. The inventory is a human artifact — it’s also your progress tracker.
- One migration brief, many agents. Write the transformation once (the upgrade guide steps, the API mappings, the pinned image tag) and hand every agent the identical brief. Divergent briefs produce divergent PRs. This is where a shared AGENTS.md or CLAUDE.md earns its keep.
- Read/plan tools only. Agents get
terraform plan, linters, and dry-runs — neverapply, never cluster credentials with write access. The reasoning is the same as in our piece on agents running Terraform. - One PR per shard. Small PRs keep review honest and let you merge incrementally instead of landing a 4,000-line change.
What review gates keep this from going wrong?
Three gates, in order: machine verification per shard, human review per PR, and serialized rollout per environment. The machine gate catches syntax and drift; the human gate catches semantics; serialization catches interactions between shards.
Machine gates are cheap and should be merciless: terraform plan output posted to the PR, kubeconform or --dry-run=server for manifests, full image build and test run for Dockerfile bumps. If a shard’s plan shows resource replacement where you expected an in-place update, that PR stops. A CI harness like our hardened Claude Code in CI setup can run these checks on every agent PR automatically.
The human gate is the bottleneck by design. Budget reviewer time as roughly equal to agent time — a reviewer skimming ten near-identical PRs starts rubber-stamping around PR four, so rotate reviewers or batch reviews across days. Merge and roll out serially: staging first, one environment at a time, with a real gap to catch what dry-runs can’t.
Where does this pattern break down?
Shared state and shared modules. Two agents editing modules that both feed the same Terraform state, or bumping a shared base module while others pin the old version, produce merge conflicts at best and plan-time surprises at worst. Anything shared gets migrated first, alone, before the fan-out starts. The other failure mode is scope creep: an agent asked to bump a provider version “helpfully” refactors variable names along the way. The brief should say, explicitly, change nothing else — and review should reject drive-by edits even when they’re improvements, because they destroy the reviewability of near-identical PRs.
Also be honest about the floor: for a codebase with six Terraform modules, sharding overhead exceeds the win. Fan-out starts paying at roughly 15–20 independent units of work.
Do you still need someone who knows the infrastructure?
Yes — more than before, just differently. Someone has to write the migration brief, decide the shard boundaries, own the review gates, and make the call when a plan diff looks wrong. That’s senior judgment applied for a few concentrated days, which is exactly the shape of engagement our $2,900/month retainer is built for: a practitioner who has run the same provider upgrade or API sweep on AWS, GCP, and Azure estates sets up the harness, and your team keeps the pattern afterward. If you’re staring down a deferred upgrade backlog, a health check is a fast way to size the actual scope before anyone spins up an agent swarm.
Newsletter
One practical DevOps guide a week
Real numbers, honest trade-offs, no vendor fog — same as everything here. Unsubscribe anytime.