Kiran-reddy9998 / Automate_S3_Using_Python

Creating S3 bucket and uploding files to it by using boto3 module with the help of Python....

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automate_S3_Using_Python

Creating S3 bucket and uploding files to it by using boto3 module with the help of Python....

AWS Configure :
( enter your aws access key id,
aws secret access key,
region name(ap-south-1),
output format(json) )

creating S3 bucket :

import boto3   #import boto3
resource = boto3.resource('s3')   #select resource (s3)
bucket = resource.Bucket("new-bucket-name") #giving name to the bucket.
bucket_properties = bucket.create(
    ACL='private',
    CreateBucketConfiguration={'LocationConstraint':'eu-central-1'}
)

print(bucket_properties)
print("Bucket created successfully......!")

Uploading file to S3 bucket.

import boto3
resource = boto3.client('s3')
resource.upload_file(
    Filename='file_1.png',
    Bucket='Bucket_Name',
    key='save_1.png'
)
print("File Uploaded to your S3 Bucket Successfully")

About

Creating S3 bucket and uploding files to it by using boto3 module with the help of Python....