I would like to know if a key exists in boto3. I can loop the bucket contents and check the key if it matches.
But that seems longer and an overkill. Boto3 official
The easiest way I found (and probably the most efficient) is this:
import boto3 from botocore.errorfactory import ClientError s3 = boto3.client('s3') try: s3.head_object(Bucket='bucket_name', Key='file_path') except ClientError: # Not found pass