Skip to content

Commit dee171a

Browse files
committed
Disable exception alerting when service is disabled
If SERVICE_ENABLED is false we put up a maintenence page which is a 503 response. This is considered an exception so it sets off our app insights exception alert. Instead we can just not enable this alert in this situation, however the rest of the alerts are still enabled as the environment is still running regardless of whether the app is serving normal requests.
1 parent eece0b0 commit dee171a

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

infrastructure/modules/container-apps/variables.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ variable "relay_namespace_name" {
206206
default = null
207207
}
208208

209+
variable "env_vars_from_yaml" {
210+
type = map(string)
211+
}
212+
209213
locals {
210214
resource_group_name = "rg-${var.app_short_name}-${var.environment}-container-app-uks"
211215

@@ -215,12 +219,9 @@ locals {
215219
database_name = "manage_breast_screening"
216220
# Here we expect the environment to be in format pr-XXX. For example PR 1234 would have environment pr-1234 and port 2234
217221
database_port = var.deploy_database_as_container ? try(tonumber(regex("\\d+", var.environment)), 24) + 1000 : 5432
218-
env_vars_from_yaml = yamldecode(
219-
file("${path.module}/../../environments/${var.env_config}/variables.yml")
220-
)
221-
external_url = "https://${module.frontdoor_endpoint.custom_domains["${var.environment}-domain"].host_name}/"
222+
external_url = "https://${module.frontdoor_endpoint.custom_domains["${var.environment}-domain"].host_name}/"
222223
common_env = merge(
223-
local.env_vars_from_yaml,
224+
var.env_vars_from_yaml,
224225
{
225226
SSL_MODE = "require"
226227
DJANGO_ENV = var.env_config

infrastructure/modules/infra/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module "app_insights_audit" {
8080
log_analytics_workspace_id = module.log_analytics_workspace_audit.id
8181

8282
action_group_id = module.monitor_action_group.monitor_action_group.id
83-
enable_alerting = var.enable_alerting
83+
enable_alerting = var.enable_alerting && locals.env_vars_from_yaml["SERVICE_ENABLED"] != false
8484
}
8585

8686
module "private_link_scoped_service_law" {

infrastructure/terraform/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module "container-apps" {
6060
enable_entra_id_authentication = var.enable_entra_id_authentication
6161
environment = var.environment
6262
env_config = var.env_config
63+
env_vars_from_yaml = local.env_vars_from_yaml
6364
fetch_secrets_from_app_key_vault = var.fetch_secrets_from_app_key_vault
6465
deploy_infra = var.deploy_infra
6566
front_door_profile = var.front_door_profile

infrastructure/terraform/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,8 @@ locals {
210210
resource_group_name = "rg-${var.app_short_name}-${var.env_config}-uks"
211211
infra_key_vault_name = "kv-${var.app_short_name}-${var.env_config}-inf"
212212
infra_key_vault_rg = "rg-${var.app_short_name}-${var.env_config}-infra"
213+
214+
env_vars_from_yaml = yamldecode(
215+
file("${path.module}/../environments/${var.env_config}/variables.yml")
216+
)
213217
}

0 commit comments

Comments
 (0)