Closed prologic closed 9 years ago
The JSON files in cloudformation are the way you describe AWS what resources you want created. They are not generated but manually authored (read note below). They can be very specific and hardcoded or they can be very generalised and reusable. It's entirely up to you. The best way to learn syntax and what resources you can use is to read the official documentation at: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html
Note: There is a way to programmatically generate JSON templates using the excellent Troposphere python library. Again, it's entirely up to you and your specific use case
And here's a link directly to some of the sample templates they provide (just follow the 'view' links):
@msessa-cotd Thank you :) Greatly appreciate this. Basically I have limited experience with AWS and zero experience with CloudFormation -- But am looking at various way we can go from our "hand built" stacks to something a bit more repeatable. Obviously Python is a great influence here (Python developer, etc) :) I'll definitely look into Troposphere - Thanks and other options to ease creating CF templates.
Troposphere (for other's benefit)
@acaire thanks :)
So after some reasons:
I don't think Troposphere is really helpful here in creating CF Templates. I think it's just as tedious doing so from a programatic API vs. JSON.
What I think could be useful though is cftpl's handling of CF Templates where it seems you can largely write CF Templates in a nicer more terse syntax YAML (albeit a subset of JSON).
Also; Q: What does cumulus do with the instance_layer.json
and vpc_layer.json
or any other JSON based CF Template you use to describe your stack? Does it just get injected into the output or manipulated in some way? (I can probably read the code...)
Troposphere comes handy when you need to programmatically generate templates. Say you have an external source of information, a CI server for example, and you want to generate a template for each one of your apps, that's one use case for it.
Templates are not manipulated in any way by cumulus. The purpose of cumulus is to help you connect multiple stacks together by automatically resolving references of resources created by other templates. This way your templates become "building blocks" of a larger infrastructure. just like lego.
Troposphere is much more suited to our use case as we require substantial loop iteration. I hadn't investigated cftpl's implementation but their Jinja2 implementation looks neat.
Initially we tried to do everything with CloudFormation Outputs but it became unwieldily, and we quickly hit the 60 Outputs limit.
Cool thanks @acaire @msessa-cotd you guys are awesome :) I might go with cumulus in fact and maybe try to come up with some ideas to make creating/managing the various CF Templates a bit easier? :) I do like cftmp's Jinja2+YAML idea a lot I also think it's neat
No worries mate :) Feel free to ask if you have any question.
I'll find some time today to update the examples with something that better represents the philosophy of building blocks.
Sounds fantastic :)
Hi @prologic, I've added a new example called 'legostack'. Hope it'll be useful to you and others.
Thank you @msessa-cotd it's greatly appreciated!
I think we can close this now! Thanks guys! Very helpful stuff!
For those new to AWS and Cloudformation -- Where do these JSON templates come from in the first place? Are they created in AWS's CloudFormation Web UI itself?