-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths3.py
More file actions
22 lines (17 loc) · 643 Bytes
/
s3.py
File metadata and controls
22 lines (17 loc) · 643 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import boto3
def list_s3_buckets():
try:
# Initialize the S3 client
s3 = boto3.client('s3')
# Retrieve list of S3 buckets
response = s3.list_buckets()
# Iterate through each bucket
for bucket in response['Buckets']:
bucket_name = bucket['Name']
creation_date = bucket['CreationDate']
# Print simple details for each bucket
print(f"Bucket Name: {bucket_name}______Created at: {creation_date}")
except Exception as e:
print(f"An error occurred: {e}")
# Call the function to list S3 buckets with simple details
list_s3_buckets()