I have an amazon s3 bucket that has tens of thousands of filenames in it. What\'s the easiest way to get a text file that lists all the filenames in the bucket?
First make sure you are on an instance terminal and you have all access of S3 in IAM you are using. For example I used an ec2 instance.
pip3 install awscli
Then Configure aws
aws configure
Then fill outcredantials ex:-
$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json (or just press enter)
Now, See all buckets
aws s3 ls
Store all buckets name
aws s3 ls > output.txt
See all file structure in a bucket
aws s3 ls bucket-name --recursive
Store file structure in each bucket
aws s3 ls bucket-name --recursive > file_Structure.txt
Hope this helps.