diff --git a/infrastructure/instance/environments/preprod/int-blue/variables.tfvars b/infrastructure/instance/environments/preprod/int-blue/variables.tfvars index 25bf77f53..996030874 100644 --- a/infrastructure/instance/environments/preprod/int-blue/variables.tfvars +++ b/infrastructure/instance/environments/preprod/int-blue/variables.tfvars @@ -3,5 +3,8 @@ immunisation_account_id = "084828561157" dspp_core_account_id = "603871901111" pds_environment = "int" error_alarm_notifications_enabled = true + +# mesh no invocation period metric set to 3 days (in seconds) for preprod environment i.e 3 * 24 * 60 * 60 +mesh_no_invocation_period_seconds = 259200 create_mesh_processor = true has_sub_environment_scope = false diff --git a/infrastructure/instance/environments/preprod/int-green/variables.tfvars b/infrastructure/instance/environments/preprod/int-green/variables.tfvars index 25bf77f53..996030874 100644 --- a/infrastructure/instance/environments/preprod/int-green/variables.tfvars +++ b/infrastructure/instance/environments/preprod/int-green/variables.tfvars @@ -3,5 +3,8 @@ immunisation_account_id = "084828561157" dspp_core_account_id = "603871901111" pds_environment = "int" error_alarm_notifications_enabled = true + +# mesh no invocation period metric set to 3 days (in seconds) for preprod environment i.e 3 * 24 * 60 * 60 +mesh_no_invocation_period_seconds = 259200 create_mesh_processor = true has_sub_environment_scope = false diff --git a/infrastructure/instance/environments/prod/blue/variables.tfvars b/infrastructure/instance/environments/prod/blue/variables.tfvars index a3349a8c1..1d94e22f0 100644 --- a/infrastructure/instance/environments/prod/blue/variables.tfvars +++ b/infrastructure/instance/environments/prod/blue/variables.tfvars @@ -3,6 +3,9 @@ immunisation_account_id = "664418956997" dspp_core_account_id = "232116723729" pds_environment = "prod" error_alarm_notifications_enabled = true + +# mesh no invocation period metric set to 1 day (in seconds) for prod environment i.e 1 * 24 * 60 * 60 +mesh_no_invocation_period_seconds = 86400 create_mesh_processor = true has_sub_environment_scope = false dspp_kms_key_alias = "nhsd-dspp-core-prod-extended-attributes-gdp-key" diff --git a/infrastructure/instance/environments/prod/green/variables.tfvars b/infrastructure/instance/environments/prod/green/variables.tfvars index 32563fb92..4f270563f 100644 --- a/infrastructure/instance/environments/prod/green/variables.tfvars +++ b/infrastructure/instance/environments/prod/green/variables.tfvars @@ -3,6 +3,9 @@ immunisation_account_id = "664418956997" dspp_core_account_id = "232116723729" pds_environment = "prod" error_alarm_notifications_enabled = true + +# mesh no invocation period metric set to 1 day (in seconds) for prod environment i.e 1 * 24 * 60 * 60 +mesh_no_invocation_period_seconds = 86400 create_mesh_processor = true has_sub_environment_scope = false dspp_kms_key_alias = "nhsd-dspp-core-prod-extended-attributes-gdp-key" \ No newline at end of file diff --git a/infrastructure/instance/mesh_processor.tf b/infrastructure/instance/mesh_processor.tf index fd3a25695..cd03dafd0 100644 --- a/infrastructure/instance/mesh_processor.tf +++ b/infrastructure/instance/mesh_processor.tf @@ -288,3 +288,25 @@ resource "aws_cloudwatch_metric_alarm" "mesh_processor_error_alarm" { alarm_actions = [data.aws_sns_topic.imms_system_alert_errors.arn] treat_missing_data = "notBreaching" } + +resource "aws_cloudwatch_metric_alarm" "mesh_processor_no_lambda_invocation_alarm" { + count = var.create_mesh_processor && var.error_alarm_notifications_enabled ? 1 : 0 + + alarm_name = "imms-${local.resource_scope}-mesh-processor-no-lambda-invocation" + alarm_description = "Triggers when the MESH Processor Lambda has no invocations for the configured time window." + + metric_name = "Invocations" + namespace = "AWS/Lambda" + statistic = "Sum" + period = var.mesh_no_invocation_period_seconds + + evaluation_periods = 1 + comparison_operator = "LessThanThreshold" + threshold = 1 + treat_missing_data = "breaching" + dimensions = { + FunctionName = aws_lambda_function.mesh_file_converter_lambda[0].function_name + } + + alarm_actions = [data.aws_sns_topic.imms_system_alert_errors.arn] +} diff --git a/infrastructure/instance/variables.tf b/infrastructure/instance/variables.tf index bd099d1f2..88a2a502b 100644 --- a/infrastructure/instance/variables.tf +++ b/infrastructure/instance/variables.tf @@ -40,6 +40,12 @@ variable "pds_environment" { default = "int" } +variable "mesh_no_invocation_period_seconds" { + description = "The maximum duration the MESH Processor Lambda can go without being invoked before the no-invocation alarm is triggered." + type = number + default = 300 +} + # Remember to switch off in PR envs after testing variable "error_alarm_notifications_enabled" { default = true