I have access key to Amazon S3 with rights limited to a certain subfolder or prefix "subfloder/". I cannot find in documentation how to access only those objects in the bucket that I have access to.
I have two access keys: the one that has read access to the whole bucket and the one with limited read/write access that I'm supposed to use. The only thing I have found is how to access collection of ObjectSummary for the whole Bucket. The following code gives me a result under bucket-access access key. However, under limited access key it gives botocore.exceptions.ClientError: Access Denied.
my_session = boto3.session.Session(aws_access_key_id=access_id, aws_secret_access_key=access_key)
s3 = my_session.resource('s3')
my_bucket = s3.Bucket(bucketname)
for obj in my_bucket.objects.filter(Prefix=prefix):
print(obj.key)
The desired result is being able to list items under restricted-access key as well as being able to call desired Object objects to run their download_fileobj() method