Created
December 8, 2017 10:07
-
-
Save gm3dmo/a64898a5904eeb709c49f652cb845778 to your computer and use it in GitHub Desktop.
Lists objects in an S3 bucket
This file contains hidden or 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
| #!/usr/local/aws/bin/python | |
| import botocore.session | |
| # wanted_profile should be set to the profile for the key you want to use | |
| # normally found in ~/.aws/credentials | |
| wanted_profile = 's3monster' | |
| wanted_bucket = 's3monsters' | |
| session1 = botocore.session.Session(profile=wanted_profile) | |
| s3_client = session1.create_client('s3') | |
| buckets = s3_client.list_buckets() | |
| # pagination! | |
| objects_in_wanted_bucket = s3_client.list_objects_v2(Bucket=wanted_bucket) | |
| print(objects_in_wanted_bucket) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment