Problem while deploying Aks using terraform in Azure

Gopi chand Narra 5 Reputation points
2024-03-04T09:10:39.5133333+00:00

getting below error while deploying aks cluster in Azure using terraform.

PS C:\Gopi\Kubernetes_cluster> .\terraform apply --auto-approve

azurerm_resource_group.name: Refreshing state... [id=/subscriptions/e4adbab1-e92f-4ad8-917b-6aaf9334f5da/resourceGroups/aksrg]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

  • create

Terraform will perform the following actions:

azurerm_kubernetes_cluster.name will be created

  • resource "azurerm_kubernetes_cluster" "name" {
    • dns_prefix = "deaultaksrababu"
    • fqdn = (known after apply)
    • http_application_routing_zone_name = (known after apply)
    • id = (known after apply)
    • kube_admin_config = (sensitive value)
    • kube_admin_config_raw = (sensitive value)
    • kube_config = (sensitive value)
    • kube_config_raw = (sensitive value)
    • kubernetes_version = "1.27.9"
    • location = "eastus2"
    • name = "akscluster0132"
    • node_resource_group = "aks_node_resource_group"
    • portal_fqdn = (known after apply)
    • private_cluster_public_fqdn_enabled = false
    • private_dns_zone_id = (known after apply)
    • private_fqdn = (known after apply)
    • public_network_access_enabled = true
    • resource_group_name = "aksrg"
    • role_based_access_control_enabled = true
    • sku_tier = "Free"
    • default_node_pool {
      • enable_auto_scaling = false
      • kubelet_disk_type = (known after apply)
      • max_pods = (known after apply)
      • name = "kubebase"
      • node_count = 4
      • node_labels = (known after apply)
      • orchestrator_version = (known after apply)
      • os_disk_size_gb = (known after apply)
      • os_disk_type = "Managed"
      • os_sku = (known after apply)
      • type = "VirtualMachineScaleSets"
      • ultra_ssd_enabled = false
      • vm_size = "E2bds_v5"
      }
    • identity {
      • principal_id = (known after apply)
      • tenant_id = (known after apply)
      • type = "SystemAssigned"
      }
    • network_profile {
      • dns_service_ip = "10.1.0.10"
      • docker_bridge_cidr = "172.17.0.1/16"
      • load_balancer_sku = "standard"
      • network_mode = (known after apply)
      • network_plugin = "kubenet"
      • network_policy = (known after apply)
      • outbound_type = "loadBalancer"
      • pod_cidr = (known after apply)
      • service_cidr = "10.1.0.0/16"
      }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

azurerm_kubernetes_cluster.name: Creating...

│ Error: creating Cluster: (Managed Cluster Name "akscluster0132" / Resource Group "aksrg"): containerservice.ManagedClustersClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="NoRegisteredProviderFound" Message="No registered resource provider found for location 'eastus2' and API version '2022-01-02-preview' for type 'managedClusters'. The supported api-versions

are '2017-08-31, 2018-03-31, 2019-02-01, 2019-04-01, 2019-06-01, 2019-08-01, 2019-10-01, 2019-11-01, 2020-01-01, 2020-02-01, 2020-03-01, 2020-04-01, 2020-06-01, 2020-07-01, 2020-09-01, 2020-11-01, 2020-12-01, 2021-02-01, 2021-03-01, 2021-05-01, 2021-07-01, 2021-08-01, 2021-09-01, 2021-10-01, 2022-01-01, 2022-02-01, 2022-03-01, 2022-04-01, 2022-06-01, 2022-07-01, 2022-07-02-preview, 2022-08-01, 2022-08-02-preview, 2022-08-03-preview, 2022-09-01, 2022-09-02-preview, 2022-10-02-preview, 2022-11-01, 2022-11-02-preview, 2023-01-01, 2023-01-02-preview, 2023-02-01, 2023-02-02-preview, 2023-03-01, 2023-03-02-preview, 2023-04-01, 2023-04-02-preview, 2023-05-01, 2023-05-02-preview, 2023-06-01, 2023-06-02-preview, 2023-07-01, 2023-07-02-preview, 2023-08-01, 2023-08-02-preview, 2023-09-01, 2023-09-02-preview, 2023-10-01, 2023-10-02-preview, 2023-11-01, 2023-11-02-preview, 2024-01-01, 2024-01-02-preview'. The supported locations are 'australiacentral, australiacentral2, australiaeast, australiasoutheast, brazilsouth, brazilsoutheast, canadacentral, canadaeast, centralindia, centralus, eastasia, eastus, eastus2, francecentral, francesouth, germanynorth, germanywestcentral, israelcentral, italynorth, japaneast, japanwest, jioindiacentral, jioindiawest, koreacentral, koreasouth, northcentralus, northeurope, norwayeast, norwaywest, polandcentral, qatarcentral, southafricanorth, southafricawest, southcentralus, southindia, southeastasia, swedencentral, switzerlandnorth, switzerlandwest, uaecentral, uaenorth, uksouth, ukwest, westcentralus, westeurope, westus, westus2, westus3'."

Microsoft Security | Intune | Configuration Manager | Deployment
Community Center | Not monitored
{count} vote

1 answer

Sort by: Most helpful
  1. Greg Hall 0 Reputation points
    2024-03-05T08:58:35.5766667+00:00

    You should try updating the PowerShell cmdlets. It looks like your deploying an old versions of the API "2022-01-02-preview" which is no longer supported.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.