Problem while deploying Aks using terraform in Azure

449 Views Asked by At

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 'australiasoutheast' 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, 20

getting this error. I have registered all the required resource providers and changed the vm size as well

I have tried deploying aks in azure using terraform. But getting the error. how to overcome this issue?

2

There are 2 best solutions below

4
Manish Bilung On

You should be using the supported API versions instead of the one you are currently using: API version '2022-01-02-preview'

0
Vinay B On

I tried to deploy Aks using terraform in Azure in selected region and I was able to provision the requrirement successfully

The error means that either the Azure Resource Provider for AKS is not registered in your subscription for the location (australiasoutheast) you selected, or the region does not support the API version (2022-01-02-preview) you're using.

It appears that 2022-01-02-preview is not a supported API version, according to the error message. You may be using an AzureRM Terraform provider or an Azure SDK that uses an API version that is not available in your chosen region. Make sure that the Azure Kubernetes Service (AKS) version you want to deploy matches the supported API versions in the australiasoutheast region.

Once recheck the registration status of the Microsoft.ContainerService resource provider.

az provider show --namespace Microsoft.ContainerService --query "registrationState"

enter image description here

You have selected australiasoutheast as your region, but some features or the preview API version of AKS may not be supported there. If your project permits, you can try a different region where the feature set you require is fully available.

How ever I tried using the same region with updated provider and I was able to provision the requirement.

My Terraform configuration:

provider "azurerm" {
  features {}
}

variable "resource_group_name" {
  description = "The name of the resource group"
  default     = "aksrgvk"
}

variable "location" {
  description = "The Azure region to deploy the resources"
  default     = "australiasoutheast"
}

variable "cluster_name" {
  description = "The name of the AKS cluster"
  default     = "akscluster0132"
}

variable "node_count" {
  description = "The number of nodes in the AKS cluster"
  default     = 1
}

resource "azurerm_resource_group" "aks" {
  name     = var.resource_group_name
  location = var.location
}

resource "azurerm_kubernetes_cluster" "aks" {
  name                = var.cluster_name
  location            = azurerm_resource_group.aks.location
  resource_group_name = azurerm_resource_group.aks.name
  dns_prefix          = "${var.cluster_name}-dns"

  default_node_pool {
    name       = "default"
    node_count = var.node_count
    vm_size    = "Standard_DS2_v2"
  }

  identity {
    type = "SystemAssigned"
  }
}

Deployment Succeeded:

enter image description here

enter image description here