Prolog and AWS

I gave a rambling short talk recently describing my project to use Prolog to administer deployments on Amazon Web Services (AWS). Here’s the source code. I completely failed to explain the reason for doing this. So let me try again in this space.

AWS can be programmatically controlled via APIs exposed as web services. There are many, many tools that offer easier access to these APIs. To do anything interesting, you have to write a complex script to accomplish a high-level goal, i.e. deploy new web servers, backup a database, expand a tier, run a new DB slave, etc. You will often end up with lots of scripts to do this or that because these scripts are imperative (a sequence of steps to achieve a goal). The scripts are imperative because the languages (Java, Python, Ruby) are imperative (the OO just makes it modular).

With Prolog I hope to build, in effect, a script generator. My Prolog code right now can query AWS and load in the initial state: all available instances, volumes, snapshots, security groups, etc. in your account. The programmer only needs to define the goal state: the way you want your AWS deployment to look. Given the appropriate rules, Prolog should be able to find a way to accomplish this goal by figuring out what set of AWS calls it should make. It is basically generating the scripts for you.

A simple example would be a goal state shutdown: no instances should be running. Let’s say right now there are 4 running servers. The Prolog system will see these 4 servers and call terminate-instance for each one. Simple, right?

A less simple example might be replicate-zone: copy the current deployment in zone A to a new availability zone B. Again the Prolog code will look at what you’ve got in zone A. Then it will try to launch the same instances in zone B.

A more complex example might be “run my website for under $100/month”. The system might explore deploying spot instances, launching 1 larger instance rather than 3 smaller ones, or whatever. It will somehow manage your resources to fit within a budget.

I’ll post my code soon, but it is a barely functional minimal prototype right now. There are lots of interesting issues to deal with like data modeling, expressing rules, inventing a DCG grammar. I’m confident it will work eventually.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s