Skip to content

Commit ca171c7

Browse files
morenovjriragh
andauthored
feat: (IAC-950) Add the possibility to specify private dns zone resource id to use for AKS private cluster (#297)
* Added the possibility to specify the private DNS zone resource id to use * Fixed syntax for the new conditional operator * Variable names adjusted and dns prefix comparison defined * feat: (IAC-950) Added variable to specify private dns zone for private AKS Cluster * feat: (IAC-950) Update the dns_prefix logic * feat: (IAC-950) Added additional info to CONFIG-VARS --------- Co-authored-by: Ritika Patil <[email protected]> Co-authored-by: Ritika Patil <[email protected]>
1 parent a3290c0 commit ca171c7

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

docs/CONFIG-VARS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ Ubuntu 20.04 LTS is the operating system used on the Jump/NFS servers. Ubuntu cr
193193
| aks_identity | Use UserAssignedIdentity or Service Principal as [AKS identity](https://docs.microsoft.com/en-us/azure/aks/concepts-identity) | string | "uai" | A value of `uai` wil create a Managed Identity based on the permissions of the authenticated user or use [`AKS_UAI_NAME`](#use-existing), if set. A value of `sp` will use values from [`CLIENT_ID`/`CLIENT_SECRET`](#azure-authentication), if set. |
194194
| ssh_public_key | File name of public ssh key for jump and nfs VM | string | "~/.ssh/id_rsa.pub" | Required with `create_jump_vm=true` or `storage_type=standard` |
195195
| cluster_api_mode | Public or private IP for the cluster api | string | "public" | Valid Values: "public", "private" |
196+
| aks_cluster_private_dns_zone_id | Specifies private DNS zone resource ID for AKS private cluster to use | string | "" | For `cluster_api_mode=private` if `aks_cluster_private_dns_zone_id` is not specified then the value `System` is used else it is set to null. For details see [Configure a private DNS zone](https://learn.microsoft.com/en-us/azure/aks/private-clusters?tabs=azure-portal#configure-a-private-dns-zone) |
196197
| aks_cluster_sku_tier | Optimizes api server for cost vs availability | string | "Free" | Valid Values: "Free", "Standard" |
197198

198199
## Node Pools

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ module "aks" {
145145
aks_cluster_node_vm_size = var.default_nodepool_vm_type
146146
aks_cluster_node_admin = var.node_vm_admin
147147
aks_cluster_ssh_public_key = try(file(var.ssh_public_key), "")
148+
aks_cluster_private_dns_zone_id = var.aks_cluster_private_dns_zone_id
148149
aks_vnet_subnet_id = module.vnet.subnets["aks"].id
149150
kubernetes_version = var.kubernetes_version
150151
aks_cluster_endpoint_public_access_cidrs = var.cluster_api_mode == "private" ? [] : local.cluster_endpoint_public_access_cidrs # "Private cluster cannot be enabled with AuthorizedIPRanges.""

modules/azure_aks/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ resource "azurerm_kubernetes_cluster" "aks" {
66
name = var.aks_cluster_name
77
location = var.aks_cluster_location
88
resource_group_name = var.aks_cluster_rg
9-
dns_prefix = var.aks_cluster_dns_prefix
9+
dns_prefix = var.aks_private_cluster == false || var.aks_cluster_private_dns_zone_id == "" ? var.aks_cluster_dns_prefix : null
10+
dns_prefix_private_cluster = var.aks_private_cluster && var.aks_cluster_private_dns_zone_id != "" ? var.aks_cluster_dns_prefix : null
11+
1012
sku_tier = var.aks_cluster_sku_tier
1113
role_based_access_control_enabled = true
1214
http_application_routing_enabled = false
@@ -16,7 +18,7 @@ resource "azurerm_kubernetes_cluster" "aks" {
1618
kubernetes_version = var.kubernetes_version
1719
api_server_authorized_ip_ranges = var.aks_cluster_endpoint_public_access_cidrs
1820
private_cluster_enabled = var.aks_private_cluster
19-
private_dns_zone_id = var.aks_private_cluster ? "System" : null
21+
private_dns_zone_id = var.aks_private_cluster && var.aks_cluster_private_dns_zone_id != "" ? var.aks_cluster_private_dns_zone_id : (var.aks_private_cluster ? "System" : null)
2022

2123
network_profile {
2224
network_plugin = var.aks_network_plugin

modules/azure_aks/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,8 @@ variable "cluster_egress_type" {
223223
type = string
224224
default = "loadBalancer"
225225
}
226+
227+
variable "aks_cluster_private_dns_zone_id" {
228+
type = string
229+
default = ""
230+
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,12 @@ variable "aks_identity" {
754754
}
755755
}
756756

757+
variable "aks_cluster_private_dns_zone_id" {
758+
description = "Specify private DNS zone resource ID for AKS private cluster to use."
759+
type = string
760+
default = ""
761+
}
762+
757763
## Message Broker - Azure Service Bus - Experimental
758764
variable "create_azure_message_broker" {
759765
description = "Allows user to create a fully managed enterprise message broker: Azure Service Bus"

0 commit comments

Comments
 (0)