Last active
June 11, 2018 06:22
-
-
Save jecolasurdo/b06c060c02a1cc870f599fb9c6789365 to your computer and use it in GitHub Desktop.
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 | |
filter="$1" | |
if [ -z "$filter" ]; then | |
echo "Please supply a filter value." | |
exit 1 | |
fi | |
groupNames=$(aws logs describe-log-groups \ | |
--log-group-name-prefix /aws/lambda/cookiecrumbler-v2 \ | |
--output text | awk '{print $4}' |\ | |
grep "$filter" |\ | |
uniq |\ | |
sort) | |
for group in $groupNames; do | |
echo "Deleting $group..." | |
if ! aws logs delete-log-group --log-group-name "$group"; then | |
echo "There was an error deleting the log group. Halting." | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment