Created
May 9, 2020 19:16
-
-
Save quiver/3f4da153bd5ac7509ce20036fc681e0c to your computer and use it in GitHub Desktop.
Bash Script to set retention periods for Lambda@Edge CloudWatch Logs in all regions.
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 | |
# L@E logs are displayed or stored in the Region closest to the location where the function executed. | |
# This Bash script sets retention periods for CloudWatch Log in all regions. | |
FUNCTION_NAME=LambdaAtEdgeFunctionName | |
LOG_GROUP=/aws/lambda/us-east-1.${FUNCTION_NAME} | |
# Possible Values: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. | |
RETENTION_IN_DAYS=30 | |
for region in `aws ec2 describe-regions --query 'Regions[].{Name:RegionName}' --output text` | |
do | |
echo ${region} | |
aws logs put-retention-policy --log-group-name $LOG_GROUP --retention-in-days $RETENTION_IN_DAYS --region ${region} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment