Initial support for RDS has just been added to boto. The code currently lives in the subversion trunk but a new boto release will be out very soon that will also include the new RDS module. To get things started, I'll give a short tutorial on using RDS.
The first thing we need to do is create a connection to the RDS service. This is done in the same way all other service connections are created in boto:
Ultimately, we want to create a new DBInstance, basically an EC2 instance that has been pre-configured to run MySQL. Before we can do that, we need to create a couple of things that are required when creating a new DBInstance. First, we will need a DBSecurityGroup. This is very similar to the SecurityGroup used in EC2 but it's considerably more simple because it is focused on only one type of application, MySQL. Within a DBSecurityGroup I can authorize access either by a CIDR block or by specifying an existing EC2 SecurityGroup. Since I'm going to be accessing my DBInstance from an EC2 instance, I'm just going to authorize the EC2 SecurityGroup that my instance is running in. Let's assume it's the group "default":
Now that we have a DBSecurityGroup created, we now need a DBParameterGroup. The DBParameterGroup is what's used to manage all of the configuration settings you would normally have in your MySQL config file. Because you don't have direct access to your DBInstance (unlike a normal EC2 instance) you need to use the DBParameterGroup to retrieve and modify the configuration settings for your DBInstance. Let's create a new one:
The ParameterGroup object in boto subclasses dict, so it behaves just like a normal mapping type. Each key in the ParameterGroup is the name of a config entry and it's value is a Parameter object. Let's explore one of the Parameters in the ParameterGroup. Because the set of parameters is quite large, RDS doesn't send all of the default parameter settings to you when you create a new ParameterGroup. To fetch them from RDS, we need to call get_params:
Because the Parameters have information about the type of the data and allowable ranges, we can do a pretty good job of validating values before sending them back to RDS with the apply method.
Now that we have a DBSecurityGroup and DBParameterGroup created, we can create our DBInstance.
At this point, RDS will start the process of bringing up a new MySQL instance based on my specifications. There are lots of other parameters available to tweak. In addition, you can do things like set the preferred maintenance window and when you would prefer to have snapshots run. To check on the status of our instance, we can do the following:
So, at this point our new DBInstance is up and running and we have the endpoint and port number we need to connect to it. One of the nice things about RDS is that once the instance is running, I can use RDS to perform a lot of the management tasks associated with the server. I can do snapshots of the server at any time, or I can automate that process. I can change any of the parameters associated with the server and decide whether I want those changes to take place immediately or to wait until the next maintenance window. I can also use the modify_dbinstance method to tell RDS to increase the allocated storage on my server or even move my instance up to a larger instance class.
The current RDS code is checked in. It's still beta quality but we will be releasing a 1.9 version of boto early next week which will include this code as well as support for VPC and a ton of bug fixes. So, if you get a chance, give the boto RDS module a try and let us know what you think.