Use an AI to generate terraform code

thumbernail IA

1. Les IA et le code

AI coding assistants are software tools that use artificial intelligence to help developers write code faster and more accurately. They do this by generating code based on prompts or by suggesting code for auto-completion as you type code in real time.

Benefits of AI coding assistants:

AI coding assistants offer a number of benefits to developers, including:

  • Increased productivity: AI coding assistants can help write code faster and more easily.
  • Improved quality and security: AI coding assistants can help avoid coding mistakes.
  • Faster learning: AI coding assistants can help you learn new programming languages by providing code examples and explanations.

2. Comparaison de d'IA spécialisée dans le code

For this blog post, I did not take a standard programming language. I took the hcl language.

  • I focused solely on Terraform to see if code-oriented AIs can help generate good quality and directly usable Terraform code.
  • I tested both vscode extensions and directly generative AIs on the internet (bard, bing)
  • I used assistants that provide all features with free tiers.
  • I was not able to use open source assistants (ex: fauxpilot) because I do not have a GPU available.
  • I did not take assistants that only cover a few programming languages.
  • Here is the list of AIs tested

vscode extensions:

In browser :

Prompt used for code generation

For our code example, we will use the following prompt:

This is a very simple prompt. 😀

Create a terraform configuration for an aks cluster in north europe location
with private link and AD integration resource prefix must be awh, The azure terraform provider version is 3.80.0

4. Extensions vscode

Liste des fonctionnalités des assistants de codage IA utilisées :

Features Bito Codeium Cody AskCodi Github Copilot
Completions Code Yes Yes Yes Yes Yes
Chat AI Yes Yes Yes Yes Yes
Traduction Code Yes Yes Yes Yes Yes
Command Line Interface Yes No No No Yes
Correction Code Yes Yes Yes No Yes
Open Source No No Yes No No
Comprend votre code local dès le départ Yes Yes No No Yes
Navigation code Yes Yes Yes No Yes
Amélioration code (propositions) Yes No Yes No Yes
Résumer les modifications récentes du code Yes No Yes No No
Générer des notes de version Yes No No No No
Suivi des références Yes Yes Yes No No
Generation Documentation Yes Yes Yes Yes Yes
Genère les test unitaires Yes Yes Yes Yes Yes
Modèle d'IA personnalisé Yes Paid feature (enterprise) No No No
Accès hors ligne No Paid feature (enterprise) No No No
Auto-hébergement No Paid feature (enterprise) Paid feature (enterprise) No No
Confidentialité du code Yes Yes Yes No Yes

4.1. Bito

Unlike Copilot, Bito works like a chatbot in VS Code. It keeps track of conversations.

4.2. Codeium

Codeium is a coding assistant powered by proprietary generative AI models and infrastructure. The AI models are trained on over 70 programming languages. It offers semi-automated code completion, intelligent search (searching for files and code within a project folder using natural language prompts), and AI-powered chat.

4.3. Cody AI

CodyAI is an AI pair programming tool similar to GitHub Copilot. The key features of CodyAI are:

Autocompletion - CodyAI suggests words, phrases, and full blocks of code based on the context of the file you are editing. You can accept or reject CodyAI's suggestions.

Converting code comments into executable code - CodyAI can convert code comments into executable code. This can be useful for documenting your code or quickly generating prototypes.

Support for multiple programming languages - CodyAI supports over 100 programming languages including Python, JavaScript, Java, C++, Go, Rust, etc.

Customization - You can customize CodyAI's suggestions based on your preferences.

Learning - CodyAI learns from your interactions with it, allowing it to provide more relevant suggestions over time.

CodyAI is a powerful tool that can help developers save time and improve code quality. It is still in development but already has the potential to compete with GitHub Copilot.

4.4. AskCodi

AskCodi is a free alternative to GitHub Copilot for VS Code. It uses OpenAI Codex to perform many AI coding assistant tasks. For example, it can be used for code suggestions, software documentation, code explanations, testing, etc. You can also use its chat feature to start a conversation with your AI programmer. AskCodi prioritizes code privacy. It does not record the code you submit to it or the code it generates.

4.5. Github Copilot

Here is the English translation:

GitHub Copilot is an AI pair programming tool that provides autocomplete suggestions as you code. It is powered by a generative AI model developed by GitHub, OpenAI, and Microsoft. The main features of GitHub Copilot are:

Autocompletion: GitHub Copilot suggests words, phrases, and full blocks of code based on the context of the file you are editing. You can accept or reject GitHub Copilot's suggestions.

Conversion of code comments into executable code: GitHub Copilot can convert code comments into executable code. This can be useful for documenting your code or for quickly generating prototypes.

Semi-automated code snippet insertion: GitHub Copilot can help you insert repetitive code blocks like functions or methods.

Code generation: GitHub Copilot can generate full code just from a simple natural language description.

5. Navigateur

5.1. Bard

Bard is a large language chatbot model developed by Google AI, trained on a massive dataset of text and code.

5.2. Bing

Bing New AI is a new web search experience powered by artificial intelligence.

It was launched by Microsoft in February 2023.

5.3. Perplexity.ai

Perplexity AI is an artificial intelligence platform that allows users to create chatbots, virtual assistants, and other conversational applications.

5.4. Claude.ai

Claude.ai is an AI text generator developed by Anthropic, a company specializing in artificial intelligence. It is able to generate text, in response to a request made by the user.

6. Résultats

6.1. AsckCodi

Code generated by AskCodi:

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.80.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "aks" {
  name     = "awh-aks-rg"
  location = "northeurope"
}

resource "azurerm_virtual_network" "aks" {
  name                = "awh-aks-vnet"
  resource_group_name = azurerm_resource_group.aks.name
  location            = azurerm_resource_group.aks.location
  address_space       = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "aks" {
  name                 = "aks-subnet"
  resource_group_name  = azurerm_resource_group.aks.name
  virtual_network_name = azurerm_virtual_network.aks.name
  address_prefixes     = ["10.0.1.0/24"]
}

resource "azurerm_kubernetes_cluster" "aks" {
  name                = "awh-aks-cluster"
  location            = azurerm_resource_group.aks.location
  resource_group_name = azurerm_resource_group.aks.name
  dns_prefix          = "awh-aks"

  private_cluster_enabled = true

  private_dns_zone_id = azurerm_private_dns_zone.private_link.id

  admin_username = "azureuser"

  agent_pool_profile {
    name            = "default"
    count           = 1
    vm_size         = "Standard_D2s_v3"
    os_type         = "Linux"
    os_disk_size_gb = 30
  }

  service_principal {
    client_id     = var.client_id
    client_secret = var.client_secret
  }

  network_profile {
    network_plugin = "azure"
    network_policy = "calico"
  }

  addon_profile {
    azure_active_directory {
      enabled                           = true
      managed                           = true
      tenant_id                         = var.tenant_id
      admin_group_object_ids            = [var.admin_group_object_id]
      user_group_object_ids             = [var.user_group_object_id]
      cluster_manager_group_object_id   = var.cluster_manager_group_object_id
      azure_rbac_user_assignment_enabled = true
    }
  }
}

resource "azurerm_private_link_service" "private_link" {
  name                = "awh-aks-private-link"
  location            = azurerm_resource_group.aks.location
  resource_group_name = azurerm_resource_group.aks.name

  ip_configuration {
    name                          = "awh-aks-privatelink-ipconfig"
    subnet_id                     = azurerm_subnet.aks.id
    private_ip_address_allocation = "Static"
    private_ip_address            = "10.0.1.100"
  }

  visibility {
    private_endpoint_network_policies {
      enable_private_endpoint_dns_registration = true
      enable_private_link_service_network_acl  = true
    }
  }
}

resource "azurerm_private_endpoint" "private_link" {
  name                = "awh-aks-private-endpoint"
  location            = azurerm_resource_group.aks.location
  resource_group_name = azurerm_resource_group.aks.name

  subnet_id                            = azurerm_subnet.aks.id
  private_link_service_id               = azurerm_private_link_service.private_link.id
  private_endpoint_network_policies_ids = [azurerm_private_dns_zone.private_link_policy.id]

  private_service_connection {
    name                           = "awh-aks-private-endpoint-connection"
    private_connection_resource_id = azurerm_kubernetes_cluster.aks.id
    group_ids                      = []
  }
}

resource "azurerm_private_dns_zone" "private_link" {
  name                = "privatelink.kubernetes"
  resource_group_name = azurerm_resource_group.aks.name
  resolution_virtual_network_ids = [azurerm_virtual_network.aks.id]
}

resource "azurerm_private_dns_zone_virtual_network_link" "private_link_link" {
  name              = "privatelink-link"
  resource_group_name = azurerm_resource_group.aks.name

  private_dns_zone_id       = azurerm_private_dns_zone.private_link.id
  virtual_network_id = azurerm_virtual_network.aks.id
}

Results:

  • Unusable configuration

  • The code generated is not satisfactory and contains many errors, defects and omissions.

for example:

The resource azurerm_kubernetes_cluster is incomplete, the part node_pool is missing.

The AI is based on a Terraform code models are not up to date.

6.2 Bito

Code generated by Bito :

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.80.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "aks" {
  name     = "awh-aks"
  location = "northeurope"
}

resource "azurerm_virtual_network" "aks" {
  name                = "awh-aks-vnet"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.aks.location
  resource_group_name = azurerm_resource_group.aks.name
}

resource "azurerm_subnet" "aks" {
  name                 = "aks-subnet"
  resource_group_name  = azurerm_resource_group.aks.name
  virtual_network_name = azurerm_virtual_network.aks.name
  address_prefixes     = ["10.0.1.0/24"]
}

resource "azurerm_kubernetes_cluster" "aks" {
  name                = "awh-aks-cluster"
  location            = azurerm_resource_group.aks.location
  resource_group_name = azurerm_resource_group.aks.name
  dns_prefix          = "awh-aks"

  private_cluster_enabled = true

  default_node_pool {
    name                = "default"
    node_count          = 1
    vm_size             = "Standard_D2_v2"
    type                = "VirtualMachineScaleSets"
    enable_auto_scaling = true
    min_count           = 1
    max_count           = 3
  }

  network_profile {
    network_plugin = "azure"
    network_policy = "azure"
  }

  addon_profile {
    azure_active_directory {
      enabled = true
    }
  }
}

Results:

  • Unusable configuration

  • The private link and AD parts are missing. The `addon_profile' section has nothing to do with it.

  • Same as 'AsckCodi'. Code models are not up to date.

The AI's answers are the same every time

6.3 CodeIum

Code generated by CodeIum

# Configure Azure provider
provider "azurerm" {
  features {}
}

# Create a resource group
resource "azurerm_resource_group" "example" {
  name     = "awh-resource-group"
  location = "North Europe"
}

# Create a virtual network
resource "azurerm_virtual_network" "example" {
  name                = "awh-virtual-network"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
}

# Create a subnet
resource "azurerm_subnet" "example" {
  name                 = "awh-subnet"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.0.1.0/24"]
}

# Create an AKS cluster
resource "azurerm_kubernetes_cluster" "example" {
  name                = "awh-aks-cluster"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  dns_prefix          = "awhakscluster"

  default_node_pool {
    name       = "default"
    node_count = 1
    vm_size    = "Standard_DS2_v2"
  }

  service_principal {
    client_id     = "YOUR_CLIENT_ID"
    client_secret = "YOUR_CLIENT_SECRET"
  }

  network_profile {
    network_plugin     = "azure"
    network_policy     = "calico"
    dns_service_ip     = "10.0.0.10"
    docker_bridge_cidr = "172.17.0.1/16"
    service_cidr       = "10.0.0.0/16"
  }

  addon_profile {
    azure_active_directory {
      enabled = true
      managed = true
    }
  }

  private_cluster_enabled = true
  private_dns_zone        = "privatelink.azure.com"
}

Results:

  • Unusable configuration
  • The arguments private_dns_zone and addon_profile are not good / well placed

6.4. CodyAI

Code generated by CodyAI:

# Configure Azure provider
provider "azurerm" {
  features {}
}

# Create resource group
resource "azurerm_resource_group" "awh" {
  name     = "awh-rg"
  location = "North Europe"
}

# Create AD application
resource "azuread_application" "awh" {
  display_name = "awh-app"
}

# Create service principal
resource "azuread_service_principal" "awh" {
  application_id = azuread_application.awh.application_id
}

# Generate random password
resource "random_password" "awh" {
  length  = 16
  special = true
}

# Create service principal password
resource "azuread_service_principal_password" "awh" {
  service_principal_id = azuread_service_principal.awh.id
  value                = random_password.awh.result
  end_date_relative    = "17520h" # 2 years
}

# Create virtual network
resource "azurerm_virtual_network" "awh" {
  name                = "awh-vnet"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.awh.location
  resource_group_name = azurerm_resource_group.awh.name
}

# Create subnet
resource "azurerm_subnet" "awh" {
  name                 = "awh-subnet"
  resource_group_name  = azurerm_resource_group.awh.name
  virtual_network_name = azurerm_virtual_network.awh.name
  address_prefixes     = ["10.0.0.0/24"]
}

# Create AKS cluster
resource "azurerm_kubernetes_cluster" "awh" {
  name                = "awh-aks"
  location            = azurerm_resource_group.awh.location
  resource_group_name = azurerm_resource_group.awh.name

  dns_prefix = "awhaks"

  default_node_pool {
    name           = "default"
    node_count     = 1
    vm_size        = "Standard_D2_v2"
    vnet_subnet_id = azurerm_subnet.awh.id
  }

  private_cluster_enabled = true

  # Enable AD integration
  azure_active_directory_role_based_access_control {
    managed                = true
    admin_group_object_ids = [""]
    client_app_id          = azuread_application.awh.application_id
    server_app_id          = azuread_application.awh.application_id
    server_app_secret      = azuread_service_principal_password.awh.value
  }
}

RResults:

At first sight, everything's okay. No Warning in VSCode interface.

The only thing to change to make it work:

  • Remove value from the resource because the password is generated dynamically.
# Create service principal password
resource "azuread_service_principal_password" "awh" {
  service_principal_id = azuread_service_principal.awh.id
  value                = random_password.awh.result
  end_date_relative    = "17520h" # 2 years
}

6.5. Github Copilot

Code generated by Github Copilot:

provider "azurerm" {
    features {}
}

resource "azurerm_resource_group" "aks" {
    name     = "awh-aks-rg"
    location = "northeurope"
}

resource "azurerm_virtual_network" "aks" {
    name                = "awh-aks-vnet"
    address_space       = ["10.0.0.0/16"]
    location            = azurerm_resource_group.aks.location
    resource_group_name = azurerm_resource_group.aks.name
}

resource "azurerm_subnet" "aks" {
    name                 = "aks-subnet"
    resource_group_name  = azurerm_resource_group.aks.name
    virtual_network_name = azurerm_virtual_network.aks.name
    address_prefixes     = ["10.0.1.0/24"]
}

resource "azurerm_kubernetes_cluster" "aks" {
    name                = "awh-aks-cluster"
    location            = azurerm_resource_group.aks.location
    resource_group_name = azurerm_resource_group.aks.name
    dns_prefix          = "awh-aks-cluster"

    private_cluster_enabled = true

    network_profile {
        network_plugin = "azure"
        network_policy = "azure"
    }

    linux_profile {
        admin_username = "azureuser"
    }

    service_principal {
        client_id     = var.client_id
        client_secret = var.client_secret
    }

    depends_on = [
        azurerm_subnet.aks
    ]
}

resource "azurerm_kubernetes_service" "aks" {
    depends_on = [
        azurerm_kubernetes_cluster.aks
    ]

    name                = "awh-aks-service"
    location            = azurerm_resource_group.aks.location
    resource_group_name = azurerm_resource_group.aks.name
    depends_on          = [azurerm_kubernetes_cluster.aks]

    private_endpoint_connections {
        name                = "awh-aks-pec"
        private_endpoint_id = var.private_endpoint_id
        subnet_id           = azurerm_subnet.aks.id
    }
}

Results :

  • Unusable configuration

  • The resource azurerm_kubernetes_cluster is incomplete. The default_node_pool parameter is missing.

6.6. Perplexity

Code generated by Perplexity :

provider "azurerm" {
  features {}
}

provider "azuread" {}

resource "azuread_application" "aks" {
  name = "aks"
}

resource "azuread_service_principal" "aks" {
  application_id = azuread_application.aks.application_id
}

resource "azuread_service_principal_password" "aks" {
  service_principal_id = azuread_service_principal.aks.id
  value                = "password"
  end_date             = "2024-01-01T01:02:03Z"
}

resource "azurerm_kubernetes_cluster" "aks" {
  name                = "aks"
  location            = "northeurope"
  resource_group_name = "rg"

  dns_prefix = "aks"

  service_cidr   = "10.0.0.0/16"
  dns_service_ip = "10.0.0.10"
  pod_cidr       = "10.244.0.0/16"

  linux_profile {
    admin_username = "azureuser"
    ssh_key {
      key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7..."
    }
  }

  service_principal {
    client_id     = azuread_service_principal.aks.application_id
    client_secret = azuread_service_principal_password.aks.value
  }

  depends_on = [
    azuread_service_principal_password.aks
  ]
}

Results:

  • Unusable configuration
  • The resource azurerm_kubernetes_cluster is incomplete. The default_node_pool parameter is missing.

6.7. Bard

Code generated by Bard:

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">= 3.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "aks-rg" {
  name     = "awh-aks-rg"
  location = "northcentralus"
}

resource "azurerm_private_dns_zone" "aks-private-dns" {
  name                = "awh-aks-private-dns"
  resource_group_name = azurerm_resource_group.aks-rg.name
}

resource "azurerm_private_dns_virtual_network_link" "aks-private-dns-link" {
  name                  = "awh-aks-private-dns-link"
  resource_group_name   = azurerm_resource_group.aks-rg.name
  private_dns_zone_name = azurerm_private_dns_zone.aks-private-dns.name
  subnet_id             = azurerm_virtual_network_subnet.aks-vnet-subnet.id
}

resource "azurerm_virtual_network" "aks-vnet" {
  name                = "awh-aks-vnet"
  location            = azurerm_resource_group.aks-rg.location
  resource_group_name = azurerm_resource_group.aks-rg.name

  address_prefixes = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "aks-vnet-subnet" {
  name                 = "awh-aks-vnet-subnet"
  virtual_network_name = azurerm_virtual_network.aks-vnet.name
  resource_group_name  = azurerm_resource_group.aks-rg.name
  address_prefix       = "10.0.0.0/24"
}

resource "azurerm_kubernetes_cluster" "aks-cluster" {
  name                = "awh-aks-cluster"
  location            = azurerm_resource_group.aks-rg.location
  resource_group_name = azurerm_resource_group.aks-rg.name

  dns_prefix = "awh-aks"

  default_node_pool {
    name       = "awh-aks-node-pool"
    node_count = 3
    vm_size    = "Standard_D2s_v3"
  }

  private_link_subnet_ids = [azurerm_private_dns_virtual_network_link.aks-private-dns-link.subnet_id]
}

resource "azurerm_ad_service_principal" "aks-service-principal" {
  application_id = azurerm_client_application.aks-service-principal.application_id
}

resource "azurerm_kubernetes_cluster_role_binding" "aks-cluster-role-binding" {
  cluster_name                = azurerm_kubernetes_cluster.aks-cluster.name
  role_definition_id          = "5b888547-1782-4e28-8552-78266df53e59"
  service_principal_object_id = azurerm_ad_service_principal.aks-service-principal.object_id
}

Results:

  • Unusable configuration
  • Resources azurerm_virtual_network and azurerm_subnet are incomplete

6.8. Bing

Code generated by Bing:

# Define the required provider and version
provider "azurerm" {
  features {}
}

# Define the resource group
resource "azurerm_resource_group" "awh_rg" {
  name     = "awh-rg"
  location = "northeurope"
}

# Define the virtual network
resource "azurerm_virtual_network" "awh_vnet" {
  name                = "awh-vnet"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.awh_rg.location
  resource_group_name = azurerm_resource_group.awh_rg.name
}

# Define the subnet for the aks cluster
resource "azurerm_subnet" "awh_subnet" {
  name                 = "awh-subnet"
  resource_group_name  = azurerm_resource_group.awh_rg.name
  virtual_network_name = azurerm_virtual_network.awh_vnet.name
  address_prefixes     = ["10.0.1.0/24"]
}

# Define the private endpoint for the aks cluster
resource "azurerm_private_endpoint" "awh_pe" {
  name                = "awh-pe"
  location            = azurerm_resource_group.awh_rg.location
  resource_group_name = azurerm_resource_group.awh_rg.name
  subnet_id           = azurerm_subnet.awh_subnet.id

  private_service_connection {
    name                           = "awh-psc"
    private_connection_resource_id = azurerm_kubernetes_cluster.awh_aks.id
    is_manual_connection           = false
    subresource_names              = ["management"]
  }
}

# Define the AD service principal for the aks cluster
resource "azuread_service_principal" "awh_sp" {
  application_id = azuread_application.awh_app.application_id
}

# Define the AD application for the aks cluster
resource "azuread_application" "awh_app" {

  display_name = "awh-app"
}

# Define the AD service principal password for the aks cluster
resource "azuread_service_principal_password" "awh_spp" {
  service_principal_id = azuread_service_principal.awh_sp.id
  #value                = "your-password-here"
  end_date_relative = "8760h"
}

# Define the aks cluster
resource "azurerm_kubernetes_cluster" "awh_aks" {
  name                = "awh-aks"
  location            = azurerm_resource_group.awh_rg.location
  resource_group_name = azurerm_resource_group.awh_rg.name
  dns_prefix          = "awh-aks"

  default_node_pool {
    name       = "default"
    node_count = 1
    vm_size    = "Standard_D2_v2"
  }

  identity {
    type = "SystemAssigned"
  }

  service_principal {
    client_id     = azuread_service_principal.awh_sp.application_id
    client_secret = azuread_service_principal_password.awh_spp.value
  }

  private_cluster_enabled = true
  private_dns_zone_id     = "System"
}

Results:

Everything's okay at first sight.

For this to happen at the plan level, as with CodyAI, you have to comment value in the resource azuread_service_principal_password

6.9. Claude

Code generated by Claude:

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=3.80.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "rg" {
  name     = "rg-awh"
  location = "northeurope"
}

resource "azurerm_virtual_network" "vnet" {
  name                = "vnet-awh"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  address_space       = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "subnet" {
  name                 = "subnet-awh"
  resource_group_name  = azurerm_resource_group.rg.name
  virtual_network_name = azurerm_virtual_network.vnet.name
  address_prefixes     = ["10.0.1.0/24"]

  delegation {
    name = "delegation"

    service_delegation {
      name    = "Microsoft.ContainerService/managedClusters"
      actions = ["Microsoft.Network/virtualNetworks/subnets/join/action", "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action"]
    }
  }
}

resource "azurerm_private_dns_zone" "dns_zone" {
  name                = "privatelink.northeurope.azmk8s.io"
  resource_group_name = azurerm_resource_group.rg.name
}

resource "azurerm_role_assignment" "role_assignment" {
  scope                = azurerm_private_dns_zone.dns_zone.id
  role_definition_name = "Private DNS Zone Contributor"
  principal_id         = azurerm_kubernetes_cluster.aks.identity[0].principal_id
}

resource "azurerm_kubernetes_cluster" "aks" {
  name                = "aks-awh"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  dns_prefix          = "aks-awh"

  default_node_pool {
    name       = "default"
    node_count = 1
    vm_size    = "Standard_D2_v2"
  }

  identity {
    type = "SystemAssigned"
  }

  private_cluster_enabled = true

  private_dns_zone_id = azurerm_private_dns_zone.dns_zone.id

  network_profile {
    network_plugin    = "azure"
    load_balancer_sku = "Standard"
  }

  azure_active_directory_role_based_access_control {
    managed                = true
    admin_group_object_ids = ["${azuread_group.aks_admin.id}"]
  }

  depends_on = [azurerm_role_assignment.role_assignment]
}

resource "azuread_group" "aks_admin" {
  display_name     = "aks-admins"
  security_enabled = true
}

Results:

  • Code generated from good invoice
  • Plan-level fixes: remove in the resource "azure_active_directory_role_based_access_control" the dependency that generates a circularity with the aks cluster resource and change Standard to standard.

7. Conclusions

The major test winners are:

  • Bing
  • CodyAI
  • Claude

The other assistants are on models that are not up to date or non-functional codes finally for terrform.

I think that for "classical" languages all the assistants pull their pins from the game.

On the other hand, for very active languages, often subject to rapid changes, the assistants are not suitable.

8. Focus CodyAI

This is a product from sourcegraph

Back in Beta

Cody is an AI-based coding assistant developed by Sourcegraph.

It is designed to help developers write, fix, and maintain their code faster and more efficiently.

Cody uses natural language (LLM) templates to provide accurate, contextual answers to technical questions and to automatically complete code in any programming language, configuration file, or documentation.

It is also able to generate unit tests, optimize the code for best practices and describe possible improvements to the code.

Cody is available for IntelliJ, VS Code, Neovim, Emacs and other popular code editors.

8.1. Video to present the creation of terraform resources



8.2. Code smell Example

Découvrez les technologies d'alter way