A Survey of using Large Language Models for Generating Infrastructure as Code (2023)

Abstract: Infrastructure as Code (IaC) is a revolutionary approach which has gained significant prominence in the Industry. IaC manages and provisions IT infrastructure using machinereadable 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.

## introduction infrastructure as code (iac) @xcite has gained significance in modern software development as a mechanism for defining and managing it infrastructure using code-based representations. with features like automation, scalability, consistency and version control @xcite , iac is revolutionising the provisioning of infrastructure. developers who are unfamiliar with this technology may find it challenging to create effective iac * * authors contributed equally templates. moreover, the manual creation of infrastructure code can be time-consuming, error-prone and challenging to maintain, especially in complex environments. large language models (llms) have emerged as a new paradigm in nlp. having been trained on a large amount of text for predicting the next word, with the given previous words and sentences by using an in-context learning mechanism, they have shown remarkable performance in downstream nlp tasks such as dialogue modelling, machine translation, question answering, text generation, sentiment analysis and so on. additionally, llms have demonstrated an ability in tasks related to code generation and validation. for instance, codeparrot, codegen @xcite , llama @xcite , google palm and openai's gpt-3.5 @xcite , gpt-4 are some of the models which are being studied and utilised for their code-generation capabilities. this leads to the promising possibility that iac configurations could be generated automatically using llms, thereby addressing the problem of a steep learning curve, as well as, enabling users to understand the complexities and adjust parameters accordingly. ## background in this section, we give a broad overview of iac, with an introduction to well-known iac platforms. this is followed by a brief overview of llms, focusing on the applications of llms for code generation and then a summary of relevant work regarding the incorporation of llms for iac generation. ## iac using llm: related works there are some related works where iac has been generated by llms. ## iac code generation process this section outlines a template for the generation of infrastructure as code through llms using terraform as an example and some basic results. ## iac using llm: safety and ethical considerations this section outlines the safety and ethical considerations of llm-generated configurations in production environments while proposing potential resolutions. ## challenges and future study limited github training data and terraform representation may produce syntactically correct but erroneous code. llms lack awareness of current practices and security, risking data exposure. they may offer unsuitable solutions, misaligned with use cases. api updates affect code quality. testing complex llm-generated iac complicates deployment. lack of best practices and comments hampers modifications. integration issues with devops tools can lead to cost inefficiencies. to mitigate challenges, we can implement a comprehensive review process by engaging domain experts, and rigorously testing generated infrastructure code. in future, we can also use llms as assistants in multi-turn iac chatbots with automatic validations. also we plan to expand our experiments using 1000 samples per task, comparing our results with open and closed-source models. frank f xu, uri alon, graham neubig, and vincent josua hellendoorn. 2022. a systematic evaluation of large language models of code. in proceedings of the 6th acm sigplan international symposium on machine programming, pages 1-10.