Create CloudFormation stacks from within Boto #786

wants to merge 2 commits into


None yet
5 participants

mikery commented May 26, 2012


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('',
    ['1', '2'],

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

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

stack = StackTemplate('my-test-stack',

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.


garnaat commented Jun 4, 2012

Hi -

Sorry for the slow response. Holidays and travel.

Anyway, this looks pretty interesting. I would definitely be interested in seeing if we could work this into boto. I think the current cloudformation support is very rudimentary and some higher level functionality would help.

I'm going to merge this to a local branch and play around with it a bit. More comments soon.


thughes commented Aug 3, 2012

I'm very interested in this. Has any more work been done or is this the latest?

mikery commented Aug 3, 2012

Mitch might have improved things in his local branch, but I'm afraid I haven't done any more work on this yet.

I specifically needed it for a named -> Route 53 migration, so I only implemented a few resources as an example and haven't used it since. If Mitch is still interested in incorporating this upstream I'm happy to add more resource types and features.


garnaat commented Aug 3, 2012

I played around with it a bit and I do like it but I haven't had any chance to extend this further. I would be very supportive of any efforts you could put forth in that direction.

mikery commented Aug 29, 2012

Please excuse the delay, I turned off Github email notifications temporarily, and forgot to turn them back on.

I am really swamped with the day job and side projects at the moment, but I will happily do some more work on this as time permits. I'll eventually add more resources - If anyone needs support for a particular resource type, let me know and I will move it up the priority list. Once a base level of functionality has been achieved, perhaps we can look at getting this incorporated in to boto proper.

@garnaat - Mitch, I'd be interested in discussing some semi-related items offline. Could you please drop me an email so I can get in touch?

Also, would you prefer me to close this pull request and re-open in future, or just leave it open?


jsmartin commented Nov 2, 2012

It seems what you are doing is very similar to python-cloudformation. I've been use it to write my CloudFormation templates in python, and then passing the complete template to boto for validation and launching.

mikery commented Nov 2, 2012

@jsmartin - yes, there is definitely some overlap here. Thanks for the heads-up, I hadn't seen this project before.

Apologies, please ignore the above pull request. It was accidentally attributed to the wrong issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment