[3970 views]
Suppose you have an amazon s3 bucket that has around hundreds or thousands of filenames in it. So what is the easiest way to get a text file that contains lists of all the filenames in that amazon s3 bucket?
AWS have their own Command Line Tools. The AWS Command Line Interface (CLI) is a unified tool to manage all the AWS services. With just AWS CLI, you can control multiple AWS services from the command line and automate them by writing your own scripts.
The AWS CLI can be installed on Linux, Windows, and macOS using pip, a package manager for Python that provides the most easy way to install, upgrade, and remove Python packages and their dependencies.
If you already have pip installed and a supported version of Python, you can install the AWS CLI with the following command:
The --upgrade option tells pip to upgrade any requirements that are already installed. The --user option tells pip to install the program to a subdirectory of your user directory to avoid modifying libraries used by your operating system.
You can also install AWS CLI using easy_install command
Once you have simply installed AWS CLI you simply run this command
Above command will show you all of the available buckets
After this you can query a specific bucket for files like this
Output:
boto is a Python interface to Amazon Web Services. For installing boto, visit boto's github page boto
After installing boto you can simply write this python script and save it as a .py file
Run this file on terminal