Skip to content

Instantly share code, notes, and snippets.

@grncdr
Created January 29, 2019 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grncdr/b80a698507c4dc981995fcb6df3beeeb to your computer and use it in GitHub Desktop.
Save grncdr/b80a698507c4dc981995fcb6df3beeeb to your computer and use it in GitHub Desktop.
One liner for setting retention policy on a set of cloudwatch log groups
#!/bin/sh
PATTERN="my-app-production"
RETENTION_IN_DAYS="30"
for group_name in $(aws logs describe-log-groups | jq -r '.logGroups[]|.logGroupName' | grep $PATTERN); do
aws logs put-retention-policy --log-group-name $group_name --retention-in-days $RETENTION_IN_DAYS;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment