File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
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)
You can’t perform that action at this time.
0 commit comments