peterkh / cumulus

Helps manage AWS CloudFormation stacks
Other
206 stars 40 forks source link

[Question]: CF Templates vpn_layer, instance_layer #30

Closed prologic closed 9 years ago

prologic commented 9 years ago

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?

msessa commented 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

acaire commented 9 years ago

And here's a link directly to some of the sample templates they provide (just follow the 'view' links):

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/sample-templates-services-us-west-2.html

prologic commented 9 years ago

@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.

prologic commented 9 years ago

Troposphere (for other's benefit)

prologic commented 9 years ago

@acaire thanks :)

prologic commented 9 years ago

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...)

msessa commented 9 years ago

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.

acaire commented 9 years ago

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.

prologic commented 9 years ago

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

msessa commented 9 years ago

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.

prologic commented 9 years ago

Sounds fantastic :)

msessa commented 9 years ago

Hi @prologic, I've added a new example called 'legostack'. Hope it'll be useful to you and others.

prologic commented 9 years ago

Thank you @msessa-cotd it's greatly appreciated!

prologic commented 9 years ago

I think we can close this now! Thanks guys! Very helpful stuff!