Skip to content

Instantly share code, notes, and snippets.

@aerostitch
Created November 4, 2017 05:29
Show Gist options
  • Select an option

  • Save aerostitch/ec2e29922c1a25b0d8a4d6845834888e to your computer and use it in GitHub Desktop.

Select an option

Save aerostitch/ec2e29922c1a25b0d8a4d6845834888e to your computer and use it in GitHub Desktop.
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