Created
September 23, 2018 23:36
-
-
Save nmolivo/40f6d3a43300724079eb7c49bb7b971f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Create list of files to download to EC2 Instance | |
from boto3.session import Session | |
ACCESS_KEY='your_access_key' | |
SECRET_KEY='your_secret_key' | |
session = Session(aws_access_key_id=ACCESS_KEY, | |
aws_secret_access_key=SECRET_KEY) | |
s3 = session.resource('s3') | |
your_bucket = s3.Bucket('name_of_s3_bucket') | |
file_list = [] | |
for s3_file in your_bucket.objects.all(): | |
#if in docs folder, and a file name greater than 5 characters, add to list. | |
if str(s3_file.key)[0:4] == "docs" and len(str(s3_file.key)) > 5: | |
file_list.append(str(s3_file.key)) | |
else: | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment