Skip to content

Instantly share code, notes, and snippets.

@pubudusj
Last active August 18, 2020 21:13
Show Gist options
  • Save pubudusj/e6949671d44a9a73186ae230b6b94dde to your computer and use it in GitHub Desktop.
Save pubudusj/e6949671d44a9a73186ae230b6b94dde to your computer and use it in GitHub Desktop.
AWS Cloudwatch delete all the log streams within a group without deleting the group
#!/bin/bash
# This is to delete all the log streams within a AWS Cloudwatch Log Group without deleting the group.
# Pass the log group name as first paramter to the script.
# jq utility required.
logGroupName=$1
for i in `aws logs describe-log-streams --log-group-name $logGroupName | jq -r '.[] | .[] | .logStreamName'`
do
echo "Deleting log stream $i"
aws logs delete-log-stream --log-group-name $logGroupName --log-stream-name $i > null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment