Skip to content

terraform apply and NoRegisteredProviderFound #639

@bandirom

Description

@bandirom

Is there an existing issue for this?

  • I have searched the existing issues

Greenfield/Brownfield provisioning

brownfield

Terraform Version

Terraform v1.10.5 on windows_386

Module Version

9.4.1

AzureRM Provider Version

3.117.0

Affected Resource(s)/Data Source(s)

module.aks.cluazapi_update_resource.aks_cluster_post_create

Terraform Configuration Files

terraform {
  required_version = ">=1.4"

  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.117.0"
    }
    azuread = {
      source  = "hashicorp/azuread"
      version = "3.1.0"
    }
    kubernetes = {
      source  = "hashicorp/kubernetes"
      version = "2.35.1"
    }
    helm = {
      source  = "hashicorp/helm"
      version = "2.17.0"
    }
  }
}


locals {
  cluster_name         = "${var.env}-${var.k8s_cluster_name}"
  dns_prefix           = "${var.env}-${var.k8s_dns_prefix}"
  node_pool_name       = "${var.env}node"
  cluster_principal_id = lookup(module.aks.cluster_identity, "principal_id")
  resource_group_name  = module.resource_group.resource_group_name
  node_resource_group  = var.k8s_node_resource_group
  kubernetes_version   = var.k8s_automatic_channel_upgrade == null ? var.k8s_version : null

  rbac_admin_group_object_ids = var.rbac_aad_enable ? var.full_access_group_id : null

  kubelogin = {
    api_version = "client.authentication.k8s.io/v1"
    command     = "kubelogin"
    args = [
      "get-token",
      "--login",
      "spn",
      "--environment",
      "AzurePublicCloud",
      "--tenant-id",
      var.tenant_id,
      "--server-id",
      module.aks_aad[0].aad_server_id,
      "--client-id",
      module.aks_aad[0].aad_spa_client_id,
      "--client-secret",
      module.aks_aad[0].aad_spa_client_secret,
    ]
  }
}

# contain only azurerm_resource_group.rg resource. Nothing special
module "resource_group" {
  source = "../resource_group"

  env      = var.env
  location = var.location
}

module "aks" {
  source  = "Azure/aks/azurerm"
  version = "9.4.1"

  cluster_name        = local.cluster_name
  location            = var.location
  resource_group_name = local.resource_group_name
  enable_auto_scaling = false
  kubernetes_version  = local.kubernetes_version
  prefix              = var.k8s_dns_prefix
  os_disk_size_gb     = var.k8s_os_disk_size
  node_resource_group = local.node_resource_group

  temporary_name_for_rotation = "noderotation"

  sku_tier                        = var.k8s_sku_tier
  identity_type                   = var.identity_type
  log_analytics_workspace_enabled = false
  automatic_channel_upgrade       = var.k8s_automatic_channel_upgrade

  agents_count = var.k8s_node_count
  agents_size  = var.k8s_vm_size

  network_plugin       = var.k8s_network_plugin
  network_policy       = var.k8s_network_policy
  net_profile_pod_cidr = var.k8s_net_profile_pod_cidr
  load_balancer_sku    = var.k8s_load_balancer_sku


  rbac_aad                          = var.rbac_aad_enable
  role_based_access_control_enabled = var.rbac_aad_enable
  rbac_aad_managed                  = var.rbac_aad_enable
  rbac_aad_admin_group_object_ids   = local.rbac_admin_group_object_ids
  rbac_aad_azure_rbac_enabled       = var.rbac_aad_enable
  local_account_disabled            = var.rbac_aad_enable

  key_vault_secrets_provider_enabled = var.key_vault_secrets_provider_enabled
  secret_rotation_interval           = "5m"

  tags = {
    env = var.env
  }
  depends_on = [module.resource_group]
}

tfvars variables values

k8s_node_count                = 5
k8s_automatic_channel_upgrade = "stable"
enable_read_only_access       = true
location = "switzerlandnorth"
k8s_sku_tier = "Free"
k8s_load_balancer_sku = "standard"
identity_type = "SystemAssigned"

Debug Output/Panic Output

When I run `terraform plan` I get


Planning failed. Terraform encountered an error while generating this plan.

Error: Failed to retrieve resource
│
│   with module.cluster.module.aks.azapi_update_resource.aks_cluster_post_create,
│   on .terraform\modules\cluster.aks\main.tf line 658, in resource "azapi_update_resource" "aks_cluster_post_create":
│  658: resource "azapi_update_resource" "aks_cluster_post_create" {
│
│ reading "Resource: (ResourceId \"/subscriptions/<subsription_id>/resourceGroups/dev-resources/providers/Microsoft.ContainerService/managedClusters/<cluster_name>\" / Api Version \"2023-01-02-preview\")":  
│ GET https://management.azure.com/subscriptions/<subsription_id>/resourceGroups/dev-resources/providers/Microsoft.ContainerService/managedClusters/<cluster_name>
│ --------------------------------------------------------------------------------
│ RESPONSE 400: 400 Bad Request
│ ERROR CODE: NoRegisteredProviderFound
│ --------------------------------------------------------------------------------
│ {
│   "error": {
│     "code": "NoRegisteredProviderFound",
│     "message": "No registered resource provider found for location 'switzerlandnorth' and API version '2023-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-08-01, 2022-09-01, 2022-11-01, 2023-01-01, 2023-02-01, 2023-03-01, 2023-04-01, 2023-04-02-preview, 2023-05-01, 2023-05-02-preview, 202
3-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, 2024-02
-01, 2024-02-02-preview, 2024-03-02-preview, 2024-04-02-preview, 2024-05-01, 2024-05-02-preview, 2024-06-01, 2024-06-02-preview, 2024-07-01, 2024-07-02-preview, 2024-08-01, 2024-08-02-preview, 2024-09-01, 2024-09-02-preview, 202
4-10-01, 2024-10-02-preview'. The supported locations are 'australiacentral, australiacentral2, australiaeast, australiasoutheast, brazilsouth, brazilsoutheast, canadacentral, canadaeast, centralindia, centralus, eastasia, eastu
s, eastus2, francecentral, francesouth, germanynorth, germanywestcentral, israelcentral, italynorth, japaneast, japanwest, jioindiacentral, jioindiawest, koreacentral, koreasouth, mexicocentral, newzealandnorth, northcentralus, 
northeurope, norwayeast, norwaywest, polandcentral, qatarcentral, southafricanorth, southafricawest, southcentralus, southindia, southeastasia, spaincentral, swedencentral, switzerlandnorth, switzerlandwest, uaecentral, uaenorth, uksouth, ukwest, westcentralus, westeurope, westus, westus2, westus3'."
│   }
│ }


My folder structure like this: 

   │main
   │   ├── module.cluster (custom module)
   │       ├── Azure/aks/azurerm module

Expected Behaviour

I also found this bug in the azure cli
Azure/azure-cli#23985 (comment)

My az cli version is

{
  "azure-cli": "2.69.0",
  "azure-cli-core": "2.69.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {}
}

Actual Behaviour

~ 1 month ago everything worked without any problems

I met this problem with Azure/aks/azurerm: v9.1.0 after that I decided to update the module version, azurerm, but it didnt resolve the issue

az provider show -n Microsoft.ContainerService -o table
Namespace                   RegistrationPolicy    RegistrationState
--------------------------  --------------------  -------------------
Microsoft.ContainerService  RegistrationRequired  Registered

Steps to Reproduce

No response

Important Factoids

No response

References

Azure/azure-cli#23985 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions