Skip to content

Commit 2601b63

Browse files
authored
File created
1 parent 8eba66f commit 2601b63

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

create_buckets.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Boto3 script for creating "n" number S3 buckets in AWS account
2+
# Script can be executed as below,
3+
# This command creates 2 buckets in default aws profile
4+
# python create_bucket.py default 2
5+
# This command creates 2 buckets in account2 aws profile
6+
# python create_bucket.py account2 2
7+
8+
import boto3
9+
import random
10+
import sys
11+
12+
boto3.setup_default_session(profile_name=sys.argv[1])
13+
count = int(sys.argv[2])
14+
15+
for i in range(0, count):
16+
random_num = random.randint(0,2002)
17+
s3 = boto3.client('s3')
18+
bucket = s3.create_bucket( Bucket='prfacct' + str(random_num),
19+
ACL='private',
20+
CreateBucketConfiguration={
21+
'LocationConstraint': 'us-west-2'}
22+
)
23+
print ("S3 Bucket: ", bucket)
24+
25+
# s3 = boto3.resource('s3')
26+
# another_bucket=s3.Bucket('perfacct' + str(random_num))
27+
# response = another_bucket.create(ACL='private',
28+
# CreateBucketConfiguration={
29+
# 'LocationConstraint': 'us-west-2'}
30+
# )
31+
32+
# print ("S3 Bucket: ", response)

0 commit comments

Comments
 (0)