Last active
January 24, 2022 21:33
-
-
Save allanbatista/45697b94863bd595b73fd11dc7f4aa55 to your computer and use it in GitHub Desktop.
Change All CloudWatch Logs Retention
This file contains 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/python3 | |
import json | |
import subprocess | |
result = subprocess.check_output(['aws', 'logs', 'describe-log-groups']).decode('utf-8') | |
result = json.loads(result)['logGroups'] | |
for log in result: | |
command = f"aws logs put-retention-policy --retention-in-days 7 --log-group-name {log['logGroupName']}" | |
print(command) | |
subprocess.check_output(command.split(' ')).decode('utf-8') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment