hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.58k stars 4.62k forks source link

Disable `authorized_ip_ranges` in `api_server_access_profile` block included in `azurerm_kubernetes_cluster` #20085

Open joselcaguilar opened 1 year ago

joselcaguilar commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.7

AzureRM Provider Version

3.39.1

Affected Resource(s)/Data Source(s)

azurerm_kubernetes_cluster

Terraform Configuration Files

dynamic "api_server_access_profile" {
    for_each = var.api_server_access_profile.authorized_ip_ranges != null || var.api_server_access_profile.vnet_integration_enabled == true ? [var.api_server_access_profile] : []
    content {
      authorized_ip_ranges     = var.private_cluster_enabled == true ? null : api_server_access_profile.value.authorized_ip_ranges
      subnet_id                = api_server_access_profile.value.subnet_id
      vnet_integration_enabled = api_server_access_profile.value.vnet_integration_enabled
    }
  }

variable "api_server_access_profile" {
  type = object({
    authorized_ip_ranges     = optional(set(string), null)
    subnet_id                = optional(string, null)
    vnet_integration_enabled = optional(bool, false)
  })
  default     = {}
}

Debug Output/Panic Output

Nothing changed in the `terraform plan`

Expected Behaviour

Remove completely the authorized_ip_ranges from azurerm_kubernetes_cluster if they were already deployed, in AzCLI it's possible passing "" or just empty as you can see here but it doesn't work in Terraform.

I have tried passing:

api_server_access_profile = {
    authorized_ip_ranges = []
}

Or even removing the dynamic "api_server_access_profile" block from azurerm_kubernetes_cluster, but it is not recognized by TF so the previous config remains.

Actual Behaviour

No response

Steps to Reproduce

terraform plan

Important Factoids

No response

References

No response

selvanayaki678 commented 1 year ago

@stephybun do you have any update on above issue?

selvanayaki678 commented 1 year ago

Do you have any workaround for the above issue? Please help me on this

mloskot commented 11 months ago

How to disable authorized IP ranges?

This is seriously annoying that Terraform can NOT perform the action equivalent to

az aks update \
    --resource-group myResourceGroup \
    --name myAKSCluster \
    --api-server-authorized-ip-ranges ""

which is officially documented by Microsoft to Disable authorized IP ranges.

Whatever method I try to clear disable the IP ranges

the IP range 0.0.0.0/32 for Allow only the outbound public IP of the Standard SKU load balancer always comes back:

image

The only way seems to go to portal.azure.com and manually tick off this setting in AKS > Networking

image

in order to disable the "Authorized IP ranges" all together:

285308924-49c5cc4c-fae6-4dad-aadd-35e7191608d1

Regression?

tspearconquest commented 4 days ago

Have you tried the alternative [""] ? As in a list containing a single empty string. Since the AZ CLI takes "", and Terraform takes [], setting [] seems to mean to do nothing to what's there, whereas [""] would pass the "" like on the CLI.