From 7ad4d97b0372b9c78e3081851f0db2d63ee0e10f Mon Sep 17 00:00:00 2001 From: Guslington Date: Wed, 3 Aug 2022 12:55:05 +1000 Subject: [PATCH] alarm to monitor total file size of an efs volume --- lib/cfnguardian/models/alarm.rb | 5 ++++- lib/cfnguardian/resources/elastic_file_system.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/cfnguardian/models/alarm.rb b/lib/cfnguardian/models/alarm.rb index bb13fa7..cd94554 100644 --- a/lib/cfnguardian/models/alarm.rb +++ b/lib/cfnguardian/models/alarm.rb @@ -299,11 +299,14 @@ def initialize(resource) end class ElasticFileSystemAlarm < BaseAlarm - def initialize(resource) + def initialize(resource, storage_class = nil) super(resource) @group = 'ElasticFileSystem' @namespace = 'AWS/EFS' @dimensions = { FileSystemId: resource['Id'] } + unless storage_class.nil? + @dimensions[:StorageClass] = storage_class + end end end diff --git a/lib/cfnguardian/resources/elastic_file_system.rb b/lib/cfnguardian/resources/elastic_file_system.rb index 968fb64..c7198b8 100644 --- a/lib/cfnguardian/resources/elastic_file_system.rb +++ b/lib/cfnguardian/resources/elastic_file_system.rb @@ -22,6 +22,18 @@ def default_alarms alarm.treat_missing_data = 'notBreaching' alarm.datapoints_to_alarm = 5 @alarms.push(alarm) + + alarm = CfnGuardian::Models::ElasticFileSystemAlarm.new(@resource, 'Total') + alarm.name = 'TotalStorageUsed' + alarm.metric_name = 'StorageBytes' + alarm.comparison_operator = 'GreaterThanThreshold' + alarm.threshold = 10000000000 # 10GB default + alarm.evaluation_periods = 60 + alarm.treat_missing_data = 'notBreaching' + alarm.datapoints_to_alarm = 30 + alarm.alarm_action = 'Task' + alarm.enabled = false + @alarms.push(alarm) end end end