In addition, the desktop environment often provides the developer with access to unique resources and leverages a developer’s full grasp of various programming languages. With this in mind, find out how to create an application that interacts with S3 using a desktop application written using Python.
Installing boto
Python uses a library namedboto
to interact with AWS. As with all Python libraries, it’s easy to install if you have the pip
utility installed. Anaconda comes with pip
, so you shouldn’t have to do anything special to perform the installation. To install boto, open a command prompt or terminal window, type pip install boto3 (don’t type the comma), and press Enter. The installation should go quickly. After a few installation lines, you should see a success message. If you’re interested, you can read more about boto.
Listing S3 buckets
The process for getting the bucket list in Python is quite short. First, you need to access theboto
library using this code:from boto.s3.connection import S3Connection
Now that you have library access, create a connection to the library using this code:
conn = S3Connection('AccessKey', 'PrivateKey')
Make sure to provide your public access key as the first argument and your private access key as the second argument. The connection, conn
, gives you access to all the S3 information. The following code retrieves a list of all your buckets and displays their names onscreen:
buckets = conn.get_all_buckets()
for bucket in buckets:
print(bucket.name)