I wrote the following Python script to download ALL files within an S3 Bucket into my current directory:
import boto3
import botocore
import os
from boto3.session import Session
ACCESS_KEY='AWS_IAM_AccessKey'
SECRET_KEY='AWS_IAM_SecretKey'
session = Session(aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY)
myBucket = s3.Bucket('S3_bucketName')
for object in thamesBucket.objects.all():
myBucket.download_file(object.key, os.path.join(os.curdir, os.path.basename(object.key)))
I'd like to further enhance this script to only pull down S3 files generated within the last 24 hours (using the Last Modified column value?) as opposed to all of them.