Skip to content

Commit aa0e9ac

Browse files
authored
[ELI-398] Added ACM alarms to terraform (#443)
* Added ACM alarms to terraform * Updated to 'standarised' severity level
1 parent 39a20d9 commit aa0e9ac

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

infrastructure/stacks/api-layer/cloudwatch_alarms.tf

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,51 @@ locals {
293293
actions_enabled = false # Disable until service is live
294294
}
295295
}
296+
297+
# ACM alarm configuration
298+
acm_alarm_config = {
299+
"CertificateExpiry44Days" = {
300+
metric_name = "DaysToExpiry"
301+
namespace = "AWS/CertificateManager"
302+
statistic = "Minimum"
303+
threshold = 44
304+
comparison_operator = "LessThanThreshold"
305+
evaluation_periods = 1
306+
period = 86400 # one day in seconds
307+
alarm_description = "ACM Certificate expiring within 44 days"
308+
severity = "warning"
309+
treat_missing_data = "notBreaching"
310+
}
311+
312+
"CertificateExpiry30Days" = {
313+
metric_name = "DaysToExpiry"
314+
namespace = "AWS/CertificateManager"
315+
statistic = "Minimum"
316+
threshold = 30
317+
comparison_operator = "LessThanThreshold"
318+
evaluation_periods = 1
319+
period = 86400 # one day in seconds
320+
alarm_description = "ACM Certificate expiring within 30 days"
321+
severity = "high"
322+
treat_missing_data = "notBreaching"
323+
}
324+
325+
"CertificateExpiry7Days" = {
326+
metric_name = "DaysToExpiry"
327+
namespace = "AWS/CertificateManager"
328+
statistic = "Minimum"
329+
threshold = 7
330+
comparison_operator = "LessThanThreshold"
331+
evaluation_periods = 1
332+
period = 86400 # one day in seconds
333+
alarm_description = "ACM Certificate expiring within 7 days"
334+
severity = "critical"
335+
treat_missing_data = "notBreaching"
336+
}
337+
}
296338
}
297339

340+
298341
# SNS Topic for CloudWatch Alarms
299342
resource "aws_sns_topic" "cloudwatch_alarms" {
300343
name = "cloudwatch-security-alarms"
@@ -418,3 +461,29 @@ resource "aws_cloudwatch_metric_alarm" "lambda_alarms" {
418461

419462
alarm_actions = [aws_sns_topic.cloudwatch_alarms.arn]
420463
}
464+
465+
# ACM CloudWatch Alarms
466+
resource "aws_cloudwatch_metric_alarm" "acm_expiry_alarms" {
467+
for_each = local.acm_alarm_config
468+
469+
alarm_name = "ACM-${each.key}"
470+
alarm_description = each.value.alarm_description
471+
namespace = each.value.namespace
472+
metric_name = each.value.metric_name
473+
statistic = each.value.statistic
474+
threshold = each.value.threshold
475+
comparison_operator = each.value.comparison_operator
476+
evaluation_periods = each.value.evaluation_periods
477+
period = each.value.period
478+
treat_missing_data = each.value.treat_missing_data
479+
480+
tags = {
481+
Environment = var.environment
482+
AlertType = "security"
483+
Service = "acm"
484+
Severity = each.value.severity
485+
ManagedBy = "terraform"
486+
}
487+
488+
alarm_actions = [aws_sns_topic.cloudwatch_alarms.arn]
489+
}

0 commit comments

Comments
 (0)