Skip to content

Instantly share code, notes, and snippets.

@EricsonWillians
Created March 18, 2022 15:39
Show Gist options
  • Save EricsonWillians/c148ff595aee8f4dec8b0c5e8a999706 to your computer and use it in GitHub Desktop.
Save EricsonWillians/c148ff595aee8f4dec8b0c5e8a999706 to your computer and use it in GitHub Desktop.
Delete all cloudwatch log groups from all regions
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