Boto 3 Resource

Resources are a higher-level abstraction compared to clients. They are generated from a JSON resource description that is present in the boto library itself. E.g. this is the resource definition for S3. Resources provide an object-oriented interface for interacting with various AWS services.

How to Create Boto 3 Resource:-

session=boto3.Session(aws_access_key_id=’’,aws_secret_access_key=’’)#Provide your access key and secret access key
s3 = session.resource(‘s3’)

How to get list of Buckets in Boto 3 Resource:-

Bucket_List=[]
for bucket in s3.buckets.all():
Bucket_List.append(bucket.name)
#Using this we can get all list of buckets present

How to Create Bucket in Boto 3 Resouce:-

s3.create_bucket(Bucket=Bucket_Name,CreateBucketConfiguration={
'LocationConstraint':'us-west-1'})
print(f"Bucket Name '{Bucket_Name}'is Created")

How to Get Contents from Bucket in Resource:-

Bucket_Data=[]
try:
my_bucket = s3.Bucket(Bucket_Name)
except Exception as e:
print(e)
for my_bucket_object in my_bucket.objects.all():
Bucket_Data.append(my_bucket_object.key)

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

SQLITE3 PYTHON

How to Install Polr on Ubuntu 20.04 with LAMP

Inodes: A Starting Point for Understanding Linux Filesystems

A ship on cloud is moving to an earth

Python & SharePoint Folders

Start using Django with Flask

Automate Bank Reconciliations using Pandas library in Jupyter notebooks

kurplazo customer care number..7384970784.7384970784..

How to Find the Second Largest Element in a List in Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hrishikesh Deshmukh

Hrishikesh Deshmukh

More from Medium

Amazon S3 for Beginners

PCEP Certification Prep — Tips and Thoughts

Python Institute — Jocquese Sanders

Advantage of AWS benefits.

Passing the AWS Certified Cloud Practitioner exam — A study guide