#!/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