@@ -14,6 +14,7 @@ Metadata:
1414 - defaultSSDThreshold
1515 - defaultVolumeThreshold
1616 - checkInterval
17+ - alarmPrefixString
1718
1819Parameters :
1920 SNStopic :
@@ -56,6 +57,11 @@ Parameters:
5657 MinValue : 5
5758 Default : 15
5859
60+ alarmPrefixString :
61+ Description : " This is the string that will be prepended to all CloudWatch alarms created by this script."
62+ Type : String
63+ Default : " FSx-ONTAP-Auto"
64+
5965Resources :
6066 LambdaRole :
6167 Type : " AWS::IAM::Role"
@@ -91,7 +97,7 @@ Resources:
9197 - Effect : " Allow"
9298 Action :
9399 - " cloudwatch:DeleteAlarms"
94- Resource : !Sub "arn:aws:cloudwatch:*:${AWS::AccountId}:alarm:FSx-ONTAP-Auto *"
100+ Resource : !Sub "arn:aws:cloudwatch:*:${AWS::AccountId}:alarm:${alarmPrefixString} *"
95101
96102 SchedulerRole :
97103 Type : " AWS::IAM::Role"
@@ -144,6 +150,7 @@ Resources:
144150 defaultCPUThreshold : !Ref defaultCPUThreshold
145151 defaultSSDThreshold : !Ref defaultSSDThreshold
146152 defaultVolumeThreshold : !Ref defaultVolumeThreshold
153+ basePrefix : !Ref alarmPrefixString
147154
148155 Code :
149156 ZipFile : |
@@ -176,8 +183,8 @@ Resources:
176183 # Lastly, you can create an override for the SSD alarm, by creating a tag
177184 # with the name "SSD_Alarm_Threshold" on the file system resource.
178185 #
179- # Version: v2.11
180- # Date: 2024-09-27-16:03:19
186+ # Version: v2.12
187+ # Date: 2024-10-01-14:58:15
181188 #
182189 ################################################################################
183190 #
@@ -221,9 +228,12 @@ Resources:
221228 #
222229 # The following is put in front of all alarms so an IAM policy can be create
223230 # that will allow this script to only be able to delete the alarms it creates.
224- # If you change this, you must also change the IAM policy. Note that the
225- # Cloudfomration template also assume the value of this variable.
226- basePrefix="FSx-ONTAP-Auto"
231+ # If you change this, you must also change the IAM policy. It can be
232+ # set via an environment variable, this is so that the CloudFormation template
233+ # can pass the value to the Lambda function. To change the value, change
234+ # the "FSx-ONTAP-Auto" string to your desired value.
235+ import os
236+ basePrefix = os.environ.get('basePrefix', "FSx-ONTAP-Auto")
227237 #
228238 # Define the prefix for the volume utilization alarm name for the CloudWatch alarms.
229239 alarmPrefixVolume=f"{basePrefix}-Volume_Utilization_for_volume_"
@@ -241,7 +251,6 @@ Resources:
241251 import botocore
242252 from botocore.config import Config
243253 import boto3
244- import os
245254 import getopt
246255 import sys
247256 import time
0 commit comments