11import boto3
2- from botocore .exceptions import ClientError
32from botocore .client import Config
3+ from botocore .exceptions import ClientError
4+
45
56def create_s3_client (access_key , secret_key , endpoint , region ):
67 """
@@ -18,9 +19,10 @@ def create_s3_client(access_key, secret_key, endpoint, region):
1819 endpoint_url = endpoint ,
1920 aws_access_key_id = access_key ,
2021 aws_secret_access_key = secret_key ,
21- config = Config (signature_version = 's3v4' )
22+ config = Config (signature_version = 's3v4' ),
2223 )
2324
25+
2426def create_bucket_if_not_exists (s3_client , bucket_name ):
2527 """
2628 Check if an S3 bucket exists, and if not, create it.
@@ -44,6 +46,7 @@ def create_bucket_if_not_exists(s3_client, bucket_name):
4446 else :
4547 print (f"Error: { e } " )
4648
49+
4750# Credentials and Connection Info
4851access_key = 'minio'
4952secret_key = 'minio123'
@@ -53,10 +56,9 @@ def create_bucket_if_not_exists(s3_client, bucket_name):
5356# Client creation and usage
5457try :
5558 s3_client = create_s3_client (access_key , secret_key , endpoint , region )
56- bucket_name = 'tpch' # Replace with your bucket name
59+ bucket_name = 'tpch' # Replace with your bucket name
5760 create_bucket_if_not_exists (s3_client , bucket_name )
58- bucket_name = 'rainforest' # Replace with your bucket name
61+ bucket_name = 'rainforest' # Replace with your bucket name
5962 create_bucket_if_not_exists (s3_client , bucket_name )
6063except :
6164 print ("Full catch, check bucket creation script at create_buckets.py" )
62-
0 commit comments