List all the existing buckets for the AWS account using Boto3.

0 votes

Hi Guys,

I have created S3 buckets in AWS. I want to list all the available buckets using the boto3 module. How can I do that?

Oct 7 in AWS by akhtar
• 33,470 points
30 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to create a client using the boto3 module. It allows you to use some attributes related to s3 as shown below.

s3 = boto3.client('s3')
response = s3.list_buckets()

# Output the bucket names
print('Existing buckets:')
for bucket in response['Buckets']:
    print(f'  {bucket["Name"]}')
answered Oct 7 by MD
• 79,390 points

Related Questions In AWS

0 votes
1 answer

List all the existing queues - AWS SQS

Yes, that's possible, you can use the ...READ MORE

answered Aug 20, 2019 in AWS by Vishal
84 views
0 votes
1 answer

List All AWS EC2 Instances using boto3.

Hi@MD, You need to import the boto3 module ...READ MORE

answered Oct 7 in AWS by akhtar
• 33,470 points
407 views
0 votes
1 answer
0 votes
1 answer

Pass account id of an AWS sub account using a variable as an argument in CloudWatch Alarm Actions with python (boto3)?

Python String and Integer concatenation >>> print("arn:aws:swf:us-east-2:{0}:action/actions/AWS_EC2.InstanceId.Stop/1.0".format(acccnum)) arn:aws:swf:us-east-2:12312312312312:action/actions/AWS_EC2.InstanceId.Stop/1.0 >>> print("arn:aws:swf:us-east-2:" ...READ MORE

answered Oct 5, 2018 in AWS by Priyaj
• 57,700 points
481 views
0 votes
1 answer
+1 vote
2 answers
0 votes
1 answer

how to get the list of aws services i am used in aws my account by using the lambda function

Hi@shalk, You can create a session in your ...READ MORE

answered Sep 24 in AWS by MD
• 79,390 points
54 views