Azure / terraform-azurerm-aks

Terraform Module for deploying an AKS cluster
MIT License
358 stars 461 forks source link

Dynamic web_app_routing block in azurerm_kubernetes_cluster #545

Closed scottmelhop closed 1 month ago

scottmelhop commented 5 months ago

Is there an existing issue for this?

Greenfield/Brownfield provisioning

greenfield

Terraform Version

1.5.7

Module Version

3.102.0

AzureRM Provider Version

3.102.0

Affected Resource(s)/Data Source(s)

azurerm_kubernetes_cluster

Terraform Configuration Files

resource "azurerm_kubernetes_cluster" "default" {
  name                              = var.name
  location                          = var.resource_group.location
  resource_group_name               = var.resource_group.name
  dns_prefix                        = var.name
  oidc_issuer_enabled               = true
  sku_tier                          = "Standard"
  node_resource_group               = "MC-${var.name}"
  role_based_access_control_enabled = true

  dynamic "web_app_routing" {
    for_each = toset(var.dns_zones)
    content {
      dns_zone_id = data.azurerm_dns_zone.dns_zone[web_app_routing.value].id
    }

  }

### tfvars variables values

```hcl
NA

Debug Output/Panic Output

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

╷
│ Error: Too many web_app_routing blocks
│ 
│   on ../../modules/aks/aks.tf line 13, in resource "azurerm_kubernetes_cluster" "default":
│   13:     content {
│ 
│ No more than 1 "web_app_routing" blocks are allowed


### Expected Behaviour

The Web App Routing plugin supports 5 dns zones. The terraform provider doesn't allow for this to be applied.

### Actual Behaviour

_No response_

### Steps to Reproduce

_No response_

### Important Factoids

_No response_

### References

_No response_
zioproto commented 5 months ago

Hello @scottmelhop

you are opening the issue against the wrong GitHub repo. You are using the azurerm_kubernetes_cluster resource directly, your issue should be filled under https://github.com/hashicorp/terraform-provider-azurerm

If you look at the documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster#dns_zone_id

dns_zone_id is the ID of a single DNS zone, not a list of zones.

You can see here how we implemented the feature in this module:

https://github.com/Azure/terraform-azurerm-aks/blob/a63510d470d59a560893223619d6c71ae0d337a8/main.tf#L527-L533

and this is the variable we use:

https://github.com/Azure/terraform-azurerm-aks/blob/a63510d470d59a560893223619d6c71ae0d337a8/variables.tf#L1368-L1378

As you see you can pass a single DNS zone. Please let me know if this helps.

lonegunmanb commented 4 months ago

@scottmelhop Is there anything we can do for you?

lonegunmanb commented 1 month ago

I'm closing this issue since no response from @scottmelhop , please feel free to reopen it if you have any further questions.