feat: porting scripts to python

This commit is contained in:
KenF
2026-01-22 09:31:32 +08:00
parent 4f71082813
commit 55d32b83ff
17 changed files with 161 additions and 37 deletions
Executable
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
r"""
Documentation
License: This program is released under the MIT License
"""
# Imports
import boto3
def getRegions(all_regions=False):
ec2 = boto3.client('ec2')
response = ec2.describe_regions(AllRegions=all_regions)
return [region['RegionName'] for region in response['Regions']]
def printResources(region_name: str):
client = boto3.client('logs', region_name=region_name)
response = client.describe_log_groups()
for logGroup in response['logGroups']:
print(f"{logGroup['logGroupName']}, {logGroup.get('retentionInDays')}, {logGroup['storedBytes']}, {region_name}")
# Main function
def main() -> None:
print("logGroupName,retentionInDays,storedBytes,region")
for r in getRegions():
printResources(r)
# Call main function
if __name__ == '__main__':
main()