Created
November 4, 2017 05:29
-
-
Save aerostitch/ec2e29922c1a25b0d8a4d6845834888e to your computer and use it in GitHub Desktop.
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
| export AWS_PROFILE=dev; for lg in $(aws logs describe-log-groups --query 'logGroups[].logGroupName' --output text); do aws logs describe-log-streams --log-group-name "${lg}" --query 'logStreams[].{arn:arn,rs:lastEventTimestamp}' --output text ; done > /tmp/${AWS_PROFILE}.out ; cp /tmp/${AWS_PROFILE}.out /tmp/{AWS_PROFILE}.sh ; sed 's/^arn:aws:logs:.*:.*:log-group:\(.*\):log-stream:\(.*\)\t\+\(.*\) *$/if [[ $(( \3 \/ 1000 )) -lt $(date +%s -d "-30 days") ]] ; then aws logs delete-log-stream --log-group-name '"'"'\1'"'"' --log-stream-name '"'"'\2'"'"'; fi/g' -i /tmp/{AWS_PROFILE}.sh; bash /tmp/{AWS_PROFILE}.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment