Best Answer · By JanBask AWS Expert
Answered on Feb 13, 2024
In the context of AWS, you can achieve this particular functionality by using AWS SDK for your preferred programming language. Here is a Python programming language example given by using the Boto3 library, which is the AWS SDK for Python:-
Import boto3
# Initialize the S3 client
S3 = boto3.client(‘s3’)
# List all buckets
Response = s3.list_buckets()
# Extract bucket names from the response
Bucket_names = [bucket[‘Name’] for bucket in response[‘Buckets’]]
# Print the list of bucket names
Print(“List of S3 buckets:”)
For name in bucket_names:
Print(name)