Skip to content

Instantly share code, notes, and snippets.

@jecolasurdo
Last active June 11, 2018 06:22
Show Gist options
  • Save jecolasurdo/b06c060c02a1cc870f599fb9c6789365 to your computer and use it in GitHub Desktop.
Save jecolasurdo/b06c060c02a1cc870f599fb9c6789365 to your computer and use it in GitHub Desktop.
#!/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