Automated Cloud Infrastructure-as-Code Reconciliation with AI Agents

Zhenning Yang, Hui Guan, Victor Nicolet, Brandon Paulsen, Joey Dodds, Daniel Kroening, Ang ChenarXiv 2025 · DOI

Managing cloud infrastructure is a constant tug-of-war between the ideal and the reality. In an ideal world, every change is made through Infrastructure-as-Code (IaC) tools like Terraform, ensuring a perfect, version-controlled "source of truth." In reality, engineers often make quick, "out-of-band" changes via the cloud console or CLI to fix urgent production incidents or experiment with scaling. This creates infrastructure drift: the code says one thing, but the cloud is doing another. When IaC scripts are next executed, they may overwrite manual fixes, leading to downtime or security vulnerabilities.

Researchers from the University of Michigan and Amazon Web Services have introduced NSync, an agentic system designed to automatically reconcile these worlds. NSync is an AI-powered agent that detects drift by analyzing cloud API logs (such as AWS CloudTrail) and automatically updates Terraform code to match the actual state of the cloud.

The Challenge of Infrastructure Drift

The core challenge of IaC reconciliation is that it is currently a manual, error-prone chore. When a DevOps engineer creates a new subnet or changes a security group manually, they must eventually "reverse engineer" that change back into their Terraform files. This is difficult due to noisy data in API logs, the lack of a safe sandbox for testing patches, and the context overload inherent in large-scale infrastructure projects.

Example of infrastructure drift where manual VM additions are reconciled into Terraform code by NSync.

The NSync Architecture

NSync uses an agentic design built on Large Language Models (specifically Claude 3.7 Sonnet) and a suite of specialized tools. Its workflow follows three main stages:

  • Intent Identification: Instead of feeding raw logs to an LLM, NSync uses a "neurosymbolic" approach. It preprocesses API traces and uses an LLM to annotate them into a standardized schema (e.g., create, delete, update). It then consolidates these to find the persistent drift—ignoring transient changes that were immediately reverted.
  • Iterative Patch Generation: The agent enters a loop: it generates a candidate patch, then uses a custom drift_report tool. This tool provides a "read-only" version of a terraform plan, showing the agent exactly how well its patch aligns with the cloud state without touching the live environment.
  • Continual Learning: NSync maintains a project-specific Knowledge Base (KB). If the agent successfully resolves a specific syntax quirk or resource mapping, it records the solution to avoid repeating mistakes in future runs.
The NSync system architecture, highlighting the Intent Identification and Patch Generation modules.

Evaluation and Results

The researchers evaluated NSync using a novel pipeline and the first major dataset for IaC reconciliation, comprising 372 drift scenarios and 5 real-world projects. The dataset includes "mega-mesh" projects with nearly 2,000 resources and 7,000+ lines of code, as well as false-positive cases to test the agent's ability to ignore non-persistent changes.

Key results include:

  • High Accuracy: NSync achieved a 0.97 pass@3 and 0.80 pass@1 accuracy, significantly outperforming a baseline Claude agent (0.71 and 0.49, respectively).
  • Token Efficiency: NSync is 1.47x more token-efficient than standard agents because it uses targeted tools and a knowledge base rather than re-reading the entire codebase.
  • Scalability: On massive enterprise-scale projects, NSync maintained a 0.94 accuracy rate.

Discussion and Future Directions

NSync demonstrates that specialized agents can effectively bridge the gap between manual cloud operations and automated code management. By using API traces as the "ground truth" and providing a read-only feedback loop, the system bypasses the risks of live execution.

Future work will focus on helping engineers distinguish between intended drift and accidental mistakes that should be reverted rather than incorporated. Additionally, while currently focused on AWS and Terraform, the architecture is designed to be generalizable to other cloud providers (Azure, GCP) and IaC frameworks (Pulumi).

Summary updated

BibTeX
@misc{yang2025automated,
  author = {Zhenning Yang and Hui Guan and Victor Nicolet and Brandon Paulsen and Joey Dodds and Daniel Kroening and Ang Chen},
  title = {{Automated Cloud Infrastructure-as-Code Reconciliation with AI Agents}},
  year = {2025},
  eprint = {2510.20211},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.20211},
}
Figure