Last active
August 22, 2023 14:56
-
-
Save billyxs/1d170ec022dcd4039827977fe0078b8a to your computer and use it in GitHub Desktop.
Delete a list of cloudwatch alarms with names that contain a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ALARM_NAME_CONTAINS_STRING='alarm-name' | |
ALARMS=$(aws cloudwatch describe-alarms \ | |
| jq '.MetricAlarms[].AlarmName' \ | |
| sed "s/\"//g" \ | |
| awk "/$ALARM_NAME_CONTAINS_STRING/") | |
for alarm in $ALARMS; | |
do | |
echo "Deleting alarm: $alarm" | |
aws cloudwatch delete-alarms --alarm-names $alarm | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
deletes alarms with spaces in the name as well.