Slide 1

Slide 1 text

Infrastructure as Code and AI - does it fit? PATRICK KOCH

Slide 2

Slide 2 text

Patrick Koch Email: patrick.koch@avl.com Blog: patrickkoch.dev LinkedIn: patkoch87 GitHub: patkoch BlueSky: @patkoch.bsky.social Mastodon: @patkoch@hostux.social Cloud Adoption Engineer, AVL List GmbH Source icons: Microsoft, HashiCorp

Slide 3

Slide 3 text

Source: kleinezeitung.at – 01.04.2024

Slide 4

Slide 4 text

Content What is Infrastructure as Code? How does GenAI work? Why focusing on Infrastructure as Code? Usages of AI tools for Infrastructure as Code Conclusion

Slide 5

Slide 5 text

What is Infrastructure as Code?

Slide 6

Slide 6 text

What is Infrastructure as Code?  Infrastructure as Code (IaC) is a method of managing and provisioning computing infrastructure through machine-readable definition files, rather than physical hardware configuration or interactive configuration tools. It's a key practice in DevOps and is used in conjunction with continuous delivery.  IaC allows developers to automate the process of setting up and managing infrastructure, which can lead to faster deployment times, more efficient use of resources, and more reliable and repeatable processes. It can be used to manage a wide range of services, including networks, virtual machines, load balancers, and connection topology. Source: GitHub Copilot

Slide 7

Slide 7 text

Example: Azure Kubernetes Cluster resource "azurerm_resource_group" "example" { name = "my-demo-rg" location = "West Europe" } resource "azurerm_kubernetes_cluster" "example" { name = "my-demo-aks" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name dns_prefix = "exampleaks1" default_node_pool { name = "default" node_count = 1 vm_size = "Standard_D2_v2" } identity { type = "SystemAssigned" } tags = { Environment = "Production" } } Azure AKS Azure Icons: Azure Public Service Icons V14, Terraform Icon: HashiCorp Brand Kit

Slide 8

Slide 8 text

What is GenAI and how does it work?

Slide 9

Slide 9 text

https://terrateam.io/blog/using-llms-to-generate-terraform-code#what-is-a-large-language-model-llm “A Large Language Model (LLM) is an artificial intelligence model or program that generates text by “predicting” the next token in a sequence. These models are trained on massive datasets, requiring substantial parallel computing resources, such as GPUs, to process and learn from the vast amounts of text data..” “Developers can interact with the LLM by providing prompts or instructions, such as ‘ChatGPT, you are a developer…’ followed by a specific code generation request. The LLM then generates code snippets or functions based on the given prompt.”

Slide 10

Slide 10 text

Why focusing on IaC?

Slide 11

Slide 11 text

“LLMs are only as good as the data they're trained on. Terraform and IaC tools are relatively new …..That means the dataset the model was trained on (mostly from GitHub) is sparse. But most of all, most companies don't put their infra code on GitHub for security reasons. So the encoding space for this kind of code is sparse….” https://www.anyshift.io/blog/navigating-ai-in-your-infrastructure-dos-don-ts-and-why-it-matters

Slide 12

Slide 12 text

https://www.hashicorp.com/resources/the-story-of-hashicorp-terraform-with-mitchell-hashimoto

Slide 13

Slide 13 text

“The exact number of GitHub repositories used to train GPT-4 isn't publicly disclosed. However, GPT-4 was trained on a diverse dataset that includes a significant amount of code from various sources, including public repositories on GitHub. This extensive dataset helps the model understand and generate code effectively.” https://github.blog/news-insights/octoverse/octoverse-2024/

Slide 14

Slide 14 text

https://medium.com/@dlaytonj2/chatgpt-show-me-the-data-sources-11e9433d57e8

Slide 15

Slide 15 text

AI and IaC Example usages of AI tools for Infrastructure as Code

Slide 16

Slide 16 text

Answering questions

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Code Generation

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Security

Slide 23

Slide 23 text

resource "azurerm_network_security_group" "sg-rdp- connection" { name = "demonsg" location = azurerm_resource_group.rg.location resource_group_name = azurerm_resource_group.rg.name security_rule { name = "tcptraffic" priority = 100 direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" destination_port_range = "*" source_address_prefix = "*" destination_address_prefix = "*" } tags = { environment = "Testing" } }

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Code Interpretation

Slide 26

Slide 26 text

param registryName string param location string = resourceGroup().location param sku string = 'Basic' resource acr 'Microsoft.ContainerRegistry/registries@2021-06-01-preview' = { name: registryName location: location sku: { name: sku } properties: { adminUserEnabled: true } }

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Are my prompts retained?

Slide 29

Slide 29 text

Source: GitHub Copilot Trust Center - GitHub Resources

Slide 30

Slide 30 text

Source: https://learn.microsoft.com/en-us/purview/retention-policies-copilot#how-retention-works-with-microsoft-copilot-for-microsoft-365

Slide 31

Slide 31 text

Source: Gemini

Slide 32

Slide 32 text

• Don‘t blindly trust your suggested IaC code • Speeds up the development • In future: game changer and crucial for cloud deployments

Slide 33

Slide 33 text

THANK YOU! ☺