💾 Archived View for ajdiaz.me › doc › 2013 › 03141-programatically-defined-infrastructure.txt captured on 2023-01-29 at 02:58:04.
⬅️ Previous capture (2022-06-04)
-=-=-=-=-=-=-
Programatically defined infrastructure for the cloud http://ajdiaz.me/doc/2013/03141-programatically-defined-infrastructure.txt Version: 2013-03-14 With the rise of cloud computing there are also new paradigms in order to provision hosts as fast as possible. In this scenario some utilities like Puppet or Chef are the most popular ones. But though the utility of that applications is well known, they only cover the OS point of view provission, but forget completely the infrastructure behind that. The idea of this paper is to use a program language to define a infrastructure running in the cloud. For that we need to create high level funtions which allow us to create resources easily, and offer a way to provision them. For example, let's suppose the following code in python (any other language could be used here): import infrastructure as i try: instance = i.create_instance(instance_type="m1.small"): volume = i.create_volume(size=20) instance.attach_volume(volume, '/dev/xvdf') except InstanceError as e: print("Unable to create instance: {}".format(str(e))) except VolumeError as e: print("Unable to create volume: {}".format(str(e))) except AttachmentError as e: print("Unable to attach volume: {}".format(str(e))) This code create a new instance and new volume, and attach the volume to the instance, catching the errors produced in the process. This piece of code is easy to iterate, or even to be included in higher-level function or class and built more complex structures, defined for each infrastructure in a custom way. At the end, we can do something like this: x = Infrastructure() if x.deploy(): x.provision()