I recently had an issue of tracking down a file on AWS S3 based only on its name. Although I thought I knew the file’s bucket location, I wasn’t sure of its full ‘path’ (i.e. key). I wrote this Python class that uses boto3
to iterate through files in a bucket and return only files that match the supplied string-pattern (unfortunately, it doesn’t look like regex is supported <sad>). I use a python decorator to time the function that does the heavy lifting, show_keys_matching pattern
. If you find yourself in a similar situation, hope it helps.
import boto3
import time