Is it possible to filter AWS S3 objects based on certain metadata entry?

I am using Python 3.6 and boto3 library to work with some objects in s3 bucket. I have created some S3 objects with metadata entries. For example,

bucketName = 'Boto3'
objectKey = 'HelloBoto.txt'
metadataDic = {'MetadataCreator':"Ehxn"}

Now I am wondering if it is possible to filter and get only those objects which have a certain metadata entry, for example,

for obj in s3Resource.Bucket(bucketName).objects.filter(Metadata="Ehsan ul haq"):
    print('{0}'.format(obj.key))

Solution 1:

No. The list_objects() command does not accept a filter.

You would need to call head_object() to obtain the metadata for each individual object.

Alternatively, you could activate Amazon S3 Inventory - Amazon Simple Storage Service, which can provide a daily listing of all objects with metadata.