Abstract: Infrastructure-as-Code (IaC) generation holds significant promise for automating cloud infrastructure provisioning. Recent advances in Large Language Models (LLMs) present a promising opportunity to democratize IaC development by generating deployable infrastructure templates from natural language descriptions. However, current evaluation focuses on syntactic correctness while ignoring deployability, the critical measure of the utility of IaC configuration files. Six state-of-the-art LLMs performed poorly on deployability, achieving only 20.8$\sim$30.2% deployment success rate on the first attempt. In this paper, we construct DPIaC-Eval, the first deployability-centric IaC template benchmark consisting of 153 real-world scenarios cross 58 unique services. Also, we propose an LLM-based deployability-centric framework, dubbed IaCGen, that uses iterative feedback mechanism encompassing format verification, syntax checking, and live deployment stages, thereby closely mirroring the real DevOps workflows. Results show that IaCGen can make 54.6$\sim$91.6% generated IaC templates from all evaluated models deployable in the first 10 iterations. Additionally, human-in-the-loop feedback that provide direct guidance for the deployability errors, can further boost the performance to over 90% passItr@25 on all evaluated LLMs. Furthermore, we explore the trustworthiness of the generated IaC templates on user intent alignment and security compliance. The poor performance (25.2% user requirement coverage and 8.4% security compliance rate) indicates a critical need for continued research in this domain.
Introduction: The Deployability Gap in IaC
Infrastructure-as-Code (IaC) is the backbone of modern cloud provisioning, yet automating its generation remains a significant challenge for Large Language Models (LLMs). While current evaluation metrics often focus on syntactic correctness (e.g., valid YAML or JSON), they overlook the most critical metric: deployability. A template that passes a syntax check can still fail in production due to "runtime" issues like missing dependencies, deprecated resource IDs, or regional constraints.
Research shows that state-of-the-art LLMs perform poorly on their first attempt, with deployment success rates often falling below 30%. This discrepancy between "looking right" and "working right" creates a massive gap between AI-generated code and production-ready infrastructure.
DPIaC-Eval: A New Benchmark for IaC
To address this, the authors constructed DPIaC-Eval, the first benchmark specifically designed to evaluate the deployability of IaC templates.
- Composition: 153 real-world scenarios covering 58 unique AWS services.
- Diversity: Tasks are categorized into five difficulty levels based on Lines of Code (LoC), resource count, and parameters.
- Source: Templates were curated from official AWS documentation and high-quality GitHub repositories, manually paired with natural language requirements.
- Multi-dimensional Evaluation: Beyond syntax, it evaluates deployability, user intent alignment, and security compliance.
Baseline Performance and the Deployability Gap
Initial evaluations using DPIaC-Eval confirm the difficulty of the task. As shown in the performance breakdown, even advanced models struggle with complex infrastructure requirements on their first attempt.
A striking finding is that 42.7% of syntactically correct templates still failed during live deployment. This proves that static analysis is insufficient for evaluating IaC utility.
The IaCGen Framework: Iterative DevOps Simulation
To bridge this gap, the authors propose IaCGen, a framework that treats LLMs like junior DevOps engineers by placing them in an iterative "fail-learn-refine" loop. Instead of a "one-shot" generation, IaCGen mimics a real-world workflow through three stages of feedback:
- Format Verification: Ensuring basic structural correctness (e.g., using
yamllint). - Syntax Checking: Verifying AWS-specific rules (e.g., using
cfn-linter). - Live Deployment: The "gold standard" test, where resources are actually provisioned in a sandbox AWS account using the
boto3SDK.
When a failure occurs, the technical error log is fed back to the LLM. This iterative process allows the model to learn from its mistakes and refine the template until it successfully deploys.
Key Results and Insights
The results of the IaCGen framework are transformative:
- Performance Leap: Success rates jumped from a baseline average of ~25% to 54.6%–91.6% within just 10 iterations.
- Human-in-the-Loop: When expert human guidance was added to resolve persistent hallucinations, success rates for Claude 3.5 and 3.7 reached 98%.
- Model Resilience: Claude models generally proved more resilient and better at following complex interdependency rules compared to other models.
- The Security Paradox: While deployability improved significantly, security remained a major concern. Only 8.4% of generated templates met basic security compliance standards, often leaving critical "front doors" open.
- Intent Alignment: Despite high deployment success, models only covered 25.2% of specific user requirements, suggesting that while the code "works," it may not fully align with the user's original intent.
Conclusion and Future Directions
The IaCGen framework demonstrates that iterative feedback is essential for generating deployable infrastructure. However, the "alarmingly low" security compliance and intent alignment scores indicate that making code run is only the first step.
Future research should focus on "security by design." The authors suggest replacing human-in-the-loop feedback with agentic Retrieval-Augmented Generation (RAG) to automatically incorporate security best practices and official documentation, potentially achieving expert-level, secure IaC generation without human intervention.
Summary updated