feat: ported all scripts from bash to python. results are now written to a spreadsheet
This commit is contained in:
@@ -7,19 +7,26 @@ License: This program is released under the MIT License
|
||||
|
||||
# Imports
|
||||
import boto3
|
||||
|
||||
from openpyxl import load_workbook
|
||||
|
||||
# Main function
|
||||
def main() -> None:
|
||||
# Open spreadsheet and add a sheet
|
||||
wb = load_workbook('aws-inventory.xlsx')
|
||||
ws = wb.create_sheet("S3")
|
||||
|
||||
s3_client = boto3.client('s3')
|
||||
|
||||
# Get the list of all buckets
|
||||
response = s3_client.list_buckets()
|
||||
|
||||
# Print the names of the buckets
|
||||
print('Buckets')
|
||||
ws.append(['Buckets'])
|
||||
for bucket in response['Buckets']:
|
||||
print(f'{bucket["Name"]}')
|
||||
ws.append([bucket["Name"]])
|
||||
|
||||
wb.save('aws-inventory.xlsx')
|
||||
|
||||
|
||||
# Call main function
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user