Last active
May 21, 2018 07:05
-
-
Save shiro01/95ecb29598531bde6b8180468879513f to your computer and use it in GitHub Desktop.
s3_bucket_contents_list
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
import boto3 | |
def lambda_handler(event, context): | |
AWS_S3_BUCKET_NAME = 'bucket_name' | |
s3_resource = boto3.resource('s3') | |
bucket = s3_resource.Bucket(AWS_S3_BUCKET_NAME) | |
result = bucket.meta.client.list_objects_v2(Bucket=bucket.name, Prefix='bucket_dir') | |
files = [o.get('Key') for o in result.get('Contents') if not o.get('Key').endswith('/')] | |
print(files) | |
return files | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment