Last active
October 18, 2019 07:26
-
-
Save mkjsix/1b2b4f8221bd4ed8f14a68abd45e9b91 to your computer and use it in GitHub Desktop.
Read retention policies for AWS CloudWatch Log Groups, for a profile and a region
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 | |
# Example - to read the logs retention policy for your default AWS account in region eu-west-1, execute the command: | |
# read-retention.sh default eu-west-1 | |
export AWS_PROFILE=$1 | |
export AWS_REGION=$2 | |
echo "AWS_PROFILE=$AWS_PROFILE, AWS_REGION=$AWS_REGION" | |
while read -r i; | |
do (printf "%s: " "$i" && aws logs describe-log-groups --region "$AWS_REGION" --log-group-name-prefix "$i" --query 'logGroups[0].retentionInDays'); | |
done < <(aws logs describe-log-groups --region "$AWS_REGION" --query 'logGroups[*].[logGroupName]' | grep / | sed 's/"//g') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment