Can we use troposphere to load existing cloud formation template (JSON) and make changes to that?

1,118 views
Skip to first unread message

Amit Gupta

unread,
Jun 25, 2015, 12:12:54 PM6/25/15
to cloudto...@googlegroups.com
Hello,

I am looking for a tool to create cloud formation templates, came across troposphere which looks promising to me.

I already created templates using plain JSON. Was wondering how can I convert them to troposphere code in a automated way OR load them to troposphere and make changes to them. 

Thanks
Amit 

Michael Barrett

unread,
Jun 25, 2015, 2:13:04 PM6/25/15
to Amit Gupta, cloudto...@googlegroups.com
There is the cfn2py script in troposphere, though it isn't perfect (its pretty hard to convert the json to python perfectly) but it can get you some of the way there usually at least.



--
You received this message because you are subscribed to the Google Groups "cloudtools-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloudtools-de...@googlegroups.com.
To post to this group, send email to cloudto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloudtools-dev/8b468366-9830-495f-9870-f4f189278b51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Amit Gupta

unread,
Jun 26, 2015, 10:05:29 AM6/26/15
to cloudto...@googlegroups.com, gp....@gmail.com
Thanks Michael!

I was wondering if troposphere can be enhanced to take json template as input when we create Template() object and render it. That way we do not need to convert json template to python code.

Amit

Michael Barrett

unread,
Jun 28, 2015, 5:33:30 PM6/28/15
to Amit Gupta, cloudto...@googlegroups.com
I'm not sure I understand the feature that you're asking for- in order for Template to manage the 'template', it needs to convert it into python first, otherwise I'm not sure what benefit it would add?  Could you give us a better idea about your use case?  Do you intend to:

1. import json template into Template object
2. Modify Template object using add_resource, add_parameter, etc
3. Have the Template object dump the newly created template, merging the original JSON with the changes in step 2

??

If so, then somewhere in there we have to turn the json into python code that the Template understands in order to allow the stuff in step 2 to be included.

Let me know if I am misunderstanding though :)

Amit Gupta

unread,
Jun 28, 2015, 7:22:14 PM6/28/15
to cloudto...@googlegroups.com, gp....@gmail.com
All you said is what I intended :)

Michael Barrett

unread,
Jun 29, 2015, 12:19:08 AM6/29/15
to Amit Gupta, cloudto...@googlegroups.com
Yeah, that's sort of what cfn2py can be used for, but it isn't perfect, and it means converting your templates into python code with the script then editing the python.

Reply all
Reply to author
Forward
0 new messages