Skip to content

Commit 8c050c7

Browse files
committed
feat: added secret expiry alerts and switch action group email to pipeline variables
1 parent 2950b89 commit 8c050c7

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

infrastructure/tf-core/key_vault.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ module "key_vault" {
77
resource_group_name = azurerm_resource_group.core[each.key].name
88
location = each.key
99

10+
enable_alerting = var.features.alerts_enabled
11+
action_group_id = var.features.alerts_enabled ? module.monitor_action_group_performance[0].monitor_action_group.id : null
12+
secret_near_expiry_alert = var.key_vault.secret_near_expiry_alert
13+
secret_expired_alert = var.key_vault.secret_expired_alert
1014
log_analytics_workspace_id = data.terraform_remote_state.audit.outputs.log_analytics_workspace_id[local.primary_region]
1115
monitor_diagnostic_setting_keyvault_enabled_logs = local.monitor_diagnostic_setting_keyvault_enabled_logs
1216
monitor_diagnostic_setting_keyvault_metrics = local.monitor_diagnostic_setting_keyvault_metrics

infrastructure/tf-core/monitor_action_group.tf

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ module "monitor_action_group_performance" {
1818
email_receiver = {
1919
email = {
2020
name = "email"
21-
email_address = data.azurerm_key_vault_secret.monitoring_email_address[local.primary_region].value
21+
email_address = var.MONITORING_EMAIL_ADDRESS
2222
}
2323
}
24-
25-
depends_on = [
26-
module.key_vault
27-
]
2824
}

infrastructure/tf-core/variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ variable "HUB_SUBSCRIPTION_ID" {
4848
type = string
4949
}
5050

51+
variable "MONITORING_EMAIL_ADDRESS" {
52+
description = "The email address for monitoring alerts"
53+
type = string
54+
}
55+
5156
variable "TARGET_SUBSCRIPTION_ID" {
5257
description = "ID of a subscription to deploy infrastructure"
5358
type = string
@@ -360,6 +365,18 @@ variable "key_vault" {
360365
soft_del_ret_days = optional(number, 7)
361366
purge_prot = optional(bool, false)
362367
sku_name = optional(string, "standard")
368+
369+
secret_near_expiry_alert = optional(object({
370+
evaluation_frequency = optional(string, "P1D") # every 24 hours
371+
window_duration = optional(string, "P1D") # last 24 hours
372+
threshold = optional(number, 1)
373+
}), {})
374+
375+
secret_expired_alert = optional(object({
376+
evaluation_frequency = optional(string, "PT15M") # every 15 mins
377+
window_duration = optional(string, "PT1H") # last 1 hour
378+
threshold = optional(number, 1)
379+
}), {})
363380
})
364381
}
365382

0 commit comments

Comments
 (0)