Last active
August 18, 2020 21:13
-
-
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
This file contains hidden or 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 | |
# 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