Created
March 18, 2022 15:39
-
-
Save EricsonWillians/c148ff595aee8f4dec8b0c5e8a999706 to your computer and use it in GitHub Desktop.
Delete all cloudwatch log groups from all regions
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
import boto3 | |
if __name__ == "__main__": | |
s = boto3.session.Session() | |
dynamodb_regions = s.get_available_regions('dynamodb') | |
for region in dynamodb_regions: | |
try: | |
logs = boto3.client('logs', region_name=region) | |
log_groups = logs.describe_log_groups()['logGroups'] | |
for log_group in log_groups: | |
print(f'Deleting log group: {log_group["logGroupName"]} in region: {region}') | |
delete_log_group = logs.delete_log_group(logGroupName=log_group['logGroupName']) | |
except Exception as e: | |
print(f'Error in region: {region}') | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment