[Paper Review] A Survey of using Large Language Models for Generating Infrastructure as Code
This survey investigates the feasibility of using Large Language Models (LLMs) to automatically generate Infrastructure as Code (IaC) configurations, evaluating GPT-3.5-Turbo and CodeParrot on 49 AWS tasks. GPT-3.5-Turbo achieved 59.18% accuracy with a single sample, significantly outperforming CodeParrot’s 8.2%, demonstrating LLMs’ strong potential for IaC generation when combined with human oversight and validation.
Infrastructure as Code (IaC) is a revolutionary approach which has gained significant prominence in the Industry. IaC manages and provisions IT infrastructure using machine-readable code by enabling automation, consistency across the environments, reproducibility, version control, error reduction and enhancement in scalability. However, IaC orchestration is often a painstaking effort which requires specialised skills as well as a lot of manual effort. Automation of IaC is a necessity in the present conditions of the Industry and in this survey, we study the feasibility of applying Large Language Models (LLM) to address this problem. LLMs are large neural network-based models which have demonstrated significant language processing abilities and shown to be capable of following a range of instructions within a broad scope. Recently, they have also been adapted for code understanding and generation tasks successfully, which makes them a promising choice for the automatic generation of IaC configurations. In this survey, we delve into the details of IaC, usage of IaC in different platforms, their challenges, LLMs in terms of code-generation aspects and the importance of LLMs in IaC along with our own experiments. Finally, we conclude by presenting the challenges in this area and highlighting the scope for future research.
Motivation & Objective
- Address the steep learning curve and manual effort required to author IaC templates by exploring automated generation using LLMs.
- Evaluate the performance of leading LLMs in generating syntactically correct and functionally correct IaC configurations across diverse AWS infrastructure tasks.
- Identify critical safety, ethical, and operational challenges in deploying LLM-generated IaC in production environments.
- Propose best practices and mitigation strategies for secure, reliable, and maintainable LLM-assisted IaC development.
- Highlight future research directions, including multi-turn IaC chatbots, larger-scale experiments, and integration with DevOps pipelines.
Proposed method
- Evaluated GPT-3.5-Turbo and CodeParrot (small 110M parameter version) on 49 standardized AWS infrastructure tasks using both single-sample and 50-sample generation strategies.
- Measured functional correctness via exact match comparison between LLM-generated and human-authored IaC configurations.
- Applied in-context learning with prompt engineering to guide LLMs in generating IaC in Terraform HCL syntax.
- Conducted ablation studies to assess the impact of sample size and model architecture on generation accuracy.
- Integrated safety and ethical considerations into the evaluation framework, including security, over-reliance, and cost risks.
- Proposed a human-in-the-loop workflow with version control, sandbox testing, and feedback loops to ensure production readiness.
Experimental results
Research questions
- RQ1How accurately can LLMs generate functionally correct Infrastructure as Code (IaC) configurations for AWS resources compared to human-authored templates?
- RQ2What is the performance difference between GPT-3.5-Turbo and CodeParrot in generating IaC across diverse infrastructure tasks?
- RQ3What are the primary safety and ethical risks associated with deploying LLM-generated IaC in production environments?
- RQ4How can human oversight, validation, and feedback mechanisms improve the reliability and security of LLM-generated IaC?
- RQ5What future research directions can enhance the scalability, correctness, and maintainability of LLM-based IaC generation?
Key findings
- GPT-3.5-Turbo achieved a success rate of 59.18% on a single-sample generation across 49 AWS tasks, significantly outperforming CodeParrot’s 8.2%.
- The 50-sample generation strategy for GPT-3.5-Turbo yielded 56.81% accuracy, indicating that multiple generations improve reliability.
- CodeParrot, despite being fine-tuned for code generation, showed minimal performance gain, achieving only 8% accuracy across both single and 50-sample settings.
- LLM-generated IaC is prone to security flaws, misconfigurations, and cost inefficiencies, especially when used without validation or human review.
- Key challenges include lack of awareness of current cloud best practices, outdated code due to API changes, and poor maintainability due to missing comments or documentation.
- Future work should focus on multi-turn IaC chatbots, larger-scale experiments (e.g., 1000 samples per task), and integrating LLMs with CI/CD pipelines through feedback loops.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.