AWS For Developers For Dummies
Book image
Explore Book Buy On Amazon
Even though many people consider the desktop dead, it still represents the most powerful and flexible method of interacting with AWS services. Using desktop applications also enable you to create environments in which local resources and cloud resources interact seamlessly under a level of control that isn’t possible using other approaches.

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 named boto 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 the boto 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)

About This Article

This article is from the book:

About the book author:

John Mueller is an author and technical editor who has written 103 books. Some of his current works include Python development books. He has also written AWS For Admins For Dummies, which provides administrators a great place to start with Amazon Web Services (AWS). John has had an interest in AWS since its inception. In fact, he wrote Mining Amazon Web Services based on that humble beginning. Be sure to read John's blog at http://blog.johnmuellerbooks.com/.

This article can be found in the category: