
Lead Image © Claudiarndt, photocase.com
Controlling Amazon Cloud with Boto
Free Floating
The Amazon Cloud offers a range of services for dynamically scaling your own server-based services, including the Elastic Compute Cloud (EC2), which is the core service, various storage offerings, load balancers, and DNS. It makes sense to control these via the web front end if you only manage a few services and the configuration rarely changes. The command-line tool, which is available from Amazon for free [1], is better suited for more complex setups.
If you want to write your own scripts to control your own cloud infrastructure, however, Boto provides an alternative in the form of an extensive Python module that largely covers the Amazon API.
Python Module
Boto was written by Mitch Garnaat, who lists a number of application examples in his blog [2]. Boto is available under an undefined free license from GitHub [3]. You can install the software using the Python Package Manager, Pip:
pip install boto
To use the library, you first need to generate a connection object that maps the connection to the respective Amazon service:
from boto.ec2 import EC2Connection conn = EC2Connection(access_key, secret_key)
As you can see, the EC2Connection
function expects two keys that you can manage via Amazon Identity and Access Management (IAM). In the Users
section of the IAM Management Console, you can go to User Actions
and select Manage Access Keys
to generate a new passkey (Figure 1). The key is immediately ready for downloading but disappears later for security reasons. In other words, you want to download the CSV file and store it in a safe place where you can find it again even six months