Skip to content

Commit 9baab2e

Browse files
grubmeshiCopilot
andcommitted
feat: add ICF compatibility to AKS module
Add manage_meshstack_platform flag, quota_definitions, documentation_url, support_url, landing_zone tags/quotas, and infrastructure outputs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 89c60fa commit 9baab2e

1 file changed

Lines changed: 74 additions & 15 deletions

File tree

modules/aks/meshstack_integration.tf

Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
variable "manage_meshstack_platform" {
2+
description = "Whether to create meshstack_platform and meshstack_landingzone resources. Set to false for infra-only deployments."
3+
type = bool
4+
default = true
5+
}
6+
17
variable "aks" {
28
description = "AKS cluster infrastructure and service principal configuration."
39
type = object({
@@ -36,14 +42,17 @@ variable "aks" {
3642
}
3743

3844
variable "meshstack_platform" {
39-
description = "meshStack platform and landing zone registration."
45+
description = "meshStack platform and landing zone registration. Required when manage_meshstack_platform is true."
46+
default = null
4047
type = object({
4148
owning_workspace_identifier = string
4249
platform_identifier = string
4350
location_identifier = optional(string, "global")
4451

45-
display_name = optional(string, "AKS Namespace")
46-
description = optional(string, "Azure Kubernetes Service (AKS). Create a k8s namespace in our AKS cluster.")
52+
display_name = optional(string, "AKS Namespace")
53+
description = optional(string, "Azure Kubernetes Service (AKS). Create a k8s namespace in our AKS cluster.")
54+
documentation_url = optional(string)
55+
support_url = optional(string)
4756

4857
disable_ssl_validation = optional(bool, true)
4958
group_name_pattern = optional(string, "aks-#{workspaceIdentifier}.#{projectIdentifier}-#{platformGroupAlias}")
@@ -52,12 +61,27 @@ variable "meshstack_platform" {
5261
send_azure_invitation_mail = optional(bool, false)
5362
redirect_url = optional(string)
5463

64+
quota_definitions = optional(list(object({
65+
quota_key = string
66+
label = string
67+
description = string
68+
unit = string
69+
max_value = number
70+
min_value = number
71+
auto_approval_threshold = number
72+
})), [])
73+
5574
landing_zone = optional(object({
5675
name = optional(string)
5776
display_name = optional(string, "AKS Default")
5877
description = optional(string, "Default AKS landing zone")
5978
automate_deletion_approval = optional(bool, true)
6079
automate_deletion_replication = optional(bool, true)
80+
tags = optional(map(list(string)), {})
81+
quotas = optional(list(object({
82+
key = string
83+
value = number
84+
})), [])
6185
kubernetes_role_mappings = optional(list(object({
6286
platform_roles = list(string)
6387
project_role_ref = object({ name = string })
@@ -84,10 +108,10 @@ terraform {
84108
}
85109

86110
locals {
87-
landing_zone_name = coalesce(
111+
landing_zone_name = var.manage_meshstack_platform ? coalesce(
88112
var.meshstack_platform.landing_zone.name,
89113
"${var.meshstack_platform.platform_identifier}-default"
90-
)
114+
) : null
91115
}
92116

93117
module "aks_meshplatform" {
@@ -116,15 +140,19 @@ data "azuread_domains" "aad_domains" {
116140
}
117141

118142
resource "meshstack_platform" "aks" {
143+
count = var.manage_meshstack_platform ? 1 : 0
144+
119145
metadata = {
120146
name = var.meshstack_platform.platform_identifier
121147
owned_by_workspace = var.meshstack_platform.owning_workspace_identifier
122148
}
123149

124150
spec = {
125-
description = var.meshstack_platform.description
126-
display_name = var.meshstack_platform.display_name
127-
endpoint = var.aks.base_url
151+
description = var.meshstack_platform.description
152+
display_name = var.meshstack_platform.display_name
153+
documentation_url = var.meshstack_platform.documentation_url
154+
support_url = var.meshstack_platform.support_url
155+
endpoint = var.aks.base_url
128156

129157
location_ref = {
130158
name = var.meshstack_platform.location_identifier
@@ -179,20 +207,25 @@ resource "meshstack_platform" "aks" {
179207
}
180208
}
181209
}
210+
211+
quota_definitions = var.meshstack_platform.quota_definitions
182212
}
183213
}
184214

185215
resource "meshstack_landingzone" "aks_default" {
216+
count = var.manage_meshstack_platform ? 1 : 0
217+
186218
metadata = {
187219
name = local.landing_zone_name
188220
owned_by_workspace = var.meshstack_platform.owning_workspace_identifier
221+
tags = var.meshstack_platform.landing_zone.tags
189222
}
190223

191224
spec = {
192225
description = var.meshstack_platform.landing_zone.description
193226
display_name = var.meshstack_platform.landing_zone.display_name
194227

195-
platform_ref = meshstack_platform.aks.metadata
228+
platform_ref = meshstack_platform.aks[0].metadata
196229

197230
automate_deletion_approval = var.meshstack_platform.landing_zone.automate_deletion_approval
198231
automate_deletion_replication = var.meshstack_platform.landing_zone.automate_deletion_replication
@@ -202,14 +235,40 @@ resource "meshstack_landingzone" "aks_default" {
202235
kubernetes_role_mappings = var.meshstack_platform.landing_zone.kubernetes_role_mappings
203236
}
204237
}
238+
239+
quotas = var.meshstack_platform.landing_zone.quotas
205240
}
206241
}
207242

208243
output "aks" {
209-
description = "AKS platform identifiers for use as var.aks in the starterkit."
210-
value = {
211-
full_platform_identifier = "${meshstack_platform.aks.metadata.name}.${var.meshstack_platform.location_identifier}"
212-
landing_zone_dev_identifier = meshstack_landingzone.aks_default.metadata.name
213-
landing_zone_prod_identifier = meshstack_landingzone.aks_default.metadata.name
214-
}
244+
description = "AKS platform identifiers for use as var.aks in the starterkit. Null when manage_meshstack_platform is false."
245+
value = var.manage_meshstack_platform ? {
246+
full_platform_identifier = "${meshstack_platform.aks[0].metadata.name}.${var.meshstack_platform.location_identifier}"
247+
landing_zone_dev_identifier = meshstack_landingzone.aks_default[0].metadata.name
248+
landing_zone_prod_identifier = meshstack_landingzone.aks_default[0].metadata.name
249+
} : null
250+
}
251+
252+
output "replicator_token" {
253+
description = "Replicator service account token."
254+
value = module.aks_meshplatform.replicator_token
255+
sensitive = true
256+
}
257+
258+
output "metering_token" {
259+
description = "Metering service account token."
260+
value = module.aks_meshplatform.metering_token
261+
sensitive = true
262+
}
263+
264+
output "replicator_service_principal" {
265+
description = "Replicator Service Principal."
266+
value = module.aks_meshplatform.replicator_service_principal
267+
sensitive = true
268+
}
269+
270+
output "replicator_service_principal_password" {
271+
description = "Password for Replicator Service Principal."
272+
value = module.aks_meshplatform.replicator_service_principal_password
273+
sensitive = true
215274
}

0 commit comments

Comments
 (0)