boto/boto — pull request #786 by mikery (2012-05-26 09:56:21+00:00)
Title: Create CloudFormation stacks from within Boto

Hi,

For an upcoming project I need to be able to generate CloudFormation stacks from Python code. Boto seems like a logical place for this code to exist, so I have put together a proof of concept to demonstrate what I would like to achieve.

Usage example:

from boto.cloudformation.template import StackTemplate, StackParameter
from boto.cloudformation.resources import RecordSet, IAMUser, IAMGroup
from boto.cloudformation import CloudFormationConnection
from pprint import pprint
import json

conn = CloudFormationConnection()

dns_record = RecordSet('example.com',
'www',
['1', '2'],
comment='testing')

resources = {
'myuser': IAMUser(groups=['group1', 'group2', {'Ref': 'mygroup'}]),
'mygroup': IAMGroup(),
'myrecord': dns_record,
}

params = {
'myparam': StackParameter('String')
}

stack = StackTemplate('my-test-stack',
resources=resources,
parameters=params)

pprint(stack.to_object())
stack_json = json.dumps(stack.to_object())
t = conn.validate_template(template_body=stack_json)

Please note, this is not yet anywhere near complete. I am only opening this pull request to get feedback on the implementation, it is not yet ready to pull.

Is there any interest in having this in boto's core? If so, I would be happy to flesh out the PoC with more resource types, docs and unit tests.