Skip to content

Commit be1cbdb

Browse files
authored
Merge pull request #232 from eyenx/feat/add-microsoft-defender-block
feat(aks): add microsoft defender support
2 parents 60c3919 + 242b671 commit be1cbdb

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

main.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ resource "azurerm_kubernetes_cluster" "main" {
141141
}
142142
}
143143
}
144+
dynamic "microsoft_defender" {
145+
for_each = var.microsoft_defender_enabled ? ["microsoft_defender"] : []
146+
147+
content {
148+
log_analytics_workspace_id = coalesce(try(var.log_analytics_workspace.id, null), azurerm_log_analytics_workspace.main[0].id)
149+
}
150+
}
144151
network_profile {
145152
network_plugin = var.network_plugin
146153
dns_service_ip = var.net_profile_dns_service_ip
@@ -165,7 +172,6 @@ resource "azurerm_kubernetes_cluster" "main" {
165172
client_secret = var.client_secret
166173
}
167174
}
168-
169175
lifecycle {
170176
precondition {
171177
condition = (var.client_id != "" && var.client_secret != "") || (var.identity_type != "")
@@ -204,4 +210,4 @@ resource "azurerm_log_analytics_solution" "main" {
204210
product = "OMSGallery/ContainerInsights"
205211
publisher = "Microsoft"
206212
}
207-
}
213+
}

variables.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ variable "log_retention_in_days" {
259259
default = 30
260260
}
261261

262+
variable "microsoft_defender_enabled" {
263+
type = bool
264+
description = "(Optional) Is Microsoft Defender on the cluster enabled?"
265+
default = false
266+
nullable = false
267+
}
268+
262269
variable "net_profile_dns_service_ip" {
263270
type = string
264271
description = "(Optional) IP address within the Kubernetes service address range that will be used by cluster service discovery (kube-dns). Changing this forces a new resource to be created."
@@ -449,4 +456,4 @@ variable "vnet_subnet_id" {
449456
type = string
450457
description = "(Optional) The ID of a Subnet where the Kubernetes Node Pool should exist. Changing this forces a new resource to be created."
451458
default = null
452-
}
459+
}

0 commit comments

Comments
 (0)