Created
September 9, 2019 18:11
-
-
Save dehli/d09e828f942d5e4c024335e8c366b288 to your computer and use it in GitHub Desktop.
clean_log_groups.sh
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
#!/usr/bin/env bash | |
echo "Which log groups would you like to remove?" | |
read LOG_GROUP | |
echo | |
LOG_GROUPS=$(aws logs describe-log-groups --query "logGroups[*].logGroupName" --output text) | |
LOG_GROUPS=($LOG_GROUPS) | |
for i in "${LOG_GROUPS[@]}" | |
do | |
: | |
if [[ $i == *"$LOG_GROUP"* ]]; then | |
if [[ $1 != "--force" ]]; then | |
echo "Delete $i? (y/n)" | |
read CONFIRM | |
else | |
CONFIRM="y" | |
fi | |
if [[ $CONFIRM == "y" ]]; then | |
echo "Deleting $i..." | |
aws logs delete-log-group --log-group-name $i | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment