Skip to content

Instantly share code, notes, and snippets.

@dehli
Created September 9, 2019 18:11
Show Gist options
  • Save dehli/d09e828f942d5e4c024335e8c366b288 to your computer and use it in GitHub Desktop.
Save dehli/d09e828f942d5e4c024335e8c366b288 to your computer and use it in GitHub Desktop.
clean_log_groups.sh
#!/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