TL;DR
This paper introduces SWE-InfraBench, a novel benchmark for evaluating Large Language Models (LLMs) on Infrastructure-as-Code (IaC) tasks, specifically focusing on incremental modifications to AWS Cloud Development Kit (CDK) code. The benchmark reveals that even state-of-the-art LLMs struggle with these complex, real-world IaC challenges, highlighting a significant gap in their current capabilities.
What Problem Does This Paper Address?
Building and managing cloud infrastructure is a critical task, and Infrastructure-as-Code (IaC) has become the standard for doing so efficiently and reliably. While LLMs have shown impressive progress in general software engineering tasks, their ability to handle IaC, particularly imperative frameworks like AWS CDK, remains largely unexplored. Existing benchmarks often focus on declarative IaC tools (like Terraform) and generating entire codebases from scratch. However, real-world IaC development typically involves incremental modifications to existing codebases based on natural language instructions. This paper addresses the need for a benchmark that accurately reflects these practical, iterative IaC development scenarios, challenging LLMs to perform realistic code edits within complex cloud infrastructure projects.
Methods
The authors introduce SWE-InfraBench, a benchmark comprising 100 diverse IaC tasks. Each task is derived from real-world AWS CDK codebases and involves modifying existing code based on natural language instructions. The correctness of the LLM's generated modifications is automatically verified using provided unit tests.
The construction of SWE-InfraBench involved a multi-stage pipeline:
- Donor Repository Selection and Task Generation: High-quality IaC repositories (both open-source and custom) were identified. An LLM was used to suggest initial task candidates, including a masked code snippet, a prompt, and unit tests. Human domain experts then reviewed and selected promising candidates.
- Critique and Refinement: A critic-based approach was employed. The system first validates that the masked code passes the tests. Then, two distinct critic LLMs evaluate the task suggestion across four dimensions: prompt vs. functional requirements alignment, implementation generality, test quality, and test completeness. Based on this feedback, the generator LLM refines the task.
- Expert Review and Finalization: Human experts conducted a final review to ensure fairness, test coverage, appropriate challenge level, and automatic validation of the canonical solution.
The benchmark tasks are stored in JSON format, including context files, natural language prompts, canonical solutions, and CDK version information.
Datasets
The primary contribution is the SWE-InfraBench dataset, consisting of 100 instruction-based tasks for modifying IaC codebases. These tasks are collected from 34 real-world AWS CDK projects. The dataset includes:
- Full AWS CDK projects.
- Specific modification instructions in natural language.
- Suites of unit tests to verify the correctness of the generated code.
The authors also mention using various LLMs for their experiments, including models from Anthropic (Claude 3 family), Google (Gemini family), OpenAI (GPT family), DeepSeek, Mistral, Meta (LLaMA family), and Alibaba (Qwen family).
Key Insights and Ideas
- IaC is Hard for LLMs: Even the most advanced LLMs struggle significantly with realistic IaC modification tasks, indicating that this domain requires specialized reasoning beyond general code generation.
- Incremental Edits are Key: The benchmark's focus on incremental code modifications, rather than full code generation, better reflects real-world development workflows and presents a more challenging evaluation.
- Reasoning Models Show Promise: LLMs with explicit reasoning capabilities (e.g., Gemini 2.5 Pro, DeepSeek R1) generally perform better than non-reasoning models, suggesting that understanding complex dependencies and logic is crucial for IaC.
- Iterative Refinement is Crucial: Multi-turn agentic approaches, where models receive feedback and attempt to correct their solutions, significantly improve performance, mimicking how human developers debug and refine code.
- Detailed Feedback Matters: High-verbosity feedback (including detailed error messages and tracebacks) is more effective than low-verbosity feedback for LLMs to improve their solutions.
Key Results
- Low Success Rates: The best-performing LLM, Claude 3.7 Sonnet, achieved only a 34% correctness rate in single-attempt tasks. Reasoning models like DeepSeek R1 reached 24%.
- Multi-Turn Improvement: Multi-turn agentic approaches significantly boosted performance. Claude 3.7 Sonnet's correctness increased to 64% with a high-verbosity two-turn approach.
- Syntax Errors Dominate: The primary type of error encountered was syntax errors (40-85% of failures), often due to incorrect property usage in CDK constructs or outdated knowledge of recent CDK versions.
- Generation Success vs. Correctness: While LLMs generally achieve high "generation success" (producing output in the correct format), their ability to produce fully correct solutions is much lower, highlighting a gap between understanding instructions and implementing them accurately.
- Consistency Varies: Models like Claude 3.7 Sonnet showed better consistency across multiple attempts, while others like Gemini 2.5 Pro, DeepSeek R1, and OpenAI 03, despite improving with more attempts, exhibited more variability.
Limitations and Future Work
- Traceback Information: The authors acknowledge that full test failure tracebacks might inadvertently help models correct solutions without true understanding, potentially overestimating performance in real-world scenarios where templates are unknown.
- Computational Cost: Multi-turn approaches and RAG (Retrieval-Augmented Generation) increase computational costs.
- Model-Specific RAG: The effectiveness of RAG strategies varies across model architectures, suggesting a need for model-specific optimization.
- Future Work: The authors suggest expanding the benchmark to include more cloud services and IaC frameworks. They also propose enabling agents with tools like search engines and bash scripts. Future evaluation strategies could incorporate static analysis, cost simulation, or LLM-as-a-Judge reviews to provide a more comprehensive assessment of generated IaC quality.
Summary updated