bazaarvoice / cloudformation-ruby-dsl

Ruby DSL for creating Cloudformation templates
Apache License 2.0
210 stars 76 forks source link

Add support for stack metadata #65

Closed scarybot closed 8 years ago

scarybot commented 8 years ago

Hi!

I recently needed to embed metadata into my stacks (as described here: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html)

So, I've added support for that. Apologies if I've missed anything obvious... this is, in fact, my very first pull request.

Cheers! James

jonaf commented 8 years ago

hi @scarybot one of the nice things that you get from having the ruby DSL is that you can use Ruby comments anywhere in the template, and still have a valid template. I expect this is the reason why we've never bothered adding support for template metadata. Is there another use-case that this covers beyond simple commentary?

scarybot commented 8 years ago

Hi Jona,

We're using it at the moment to store data about expected versions of software and state of databases on instances inside the stack. Puppet is retrieving this metadata as an object and using it to make decisions about how to provision the machines. This way we are able to deploy new versions simply by updating the cloudformation template and running puppet.

J On Fri, 16 Oct 2015 at 16:31, Jona Fenocchi notifications@github.com wrote:

hi @scarybot https://github.com/scarybot one of the nice things that you get from having the ruby DSL is that you can use Ruby comments anywhere in the template, and still have a valid template. I expect this is the reason why we've never bothered adding support for template metadata. Is there another use-case that this covers beyond simple commentary?

— Reply to this email directly or view it on GitHub https://github.com/bazaarvoice/cloudformation-ruby-dsl/pull/65#issuecomment-148747476 .

jonaf commented 8 years ago

I think it might be worth considering a slight alteration to your implementation. Thus far, the pattern has always been to manage properties independently. What if we implemented it so that the usage looked something like:

metadata :MyKey => 'my value (can be any type)'

Or perhaps:

metadata 'MyKey', 'my value'

This way you don't have to build a complete map of your metadata or copy-modify-write to make changes to it throughout your template, and you get better declaration of the distinct attributes (nothing hidden).

scarybot commented 8 years ago

Thanks for the feedback; that seems like a better form - I'll modify and resubmit. J

On Mon, 19 Oct 2015 at 18:24 Jona Fenocchi notifications@github.com wrote:

I think it might be worth considering a slight alteration to your implementation. Thus far, the pattern has always been to manage properties independently. What if we implemented it so that the usage looked something like:

metadata :MyKey => 'my value (can be any type)'

Or perhaps:

metadata 'MyKey', 'my value'

This way you don't have to build a complete map of your metadata or copy-modify-write to make changes to it throughout your template, and you get better declaration of the distinct attributes (nothing hidden).

— Reply to this email directly or view it on GitHub https://github.com/bazaarvoice/cloudformation-ruby-dsl/pull/65#issuecomment-149288118 .

Carles-Figuerola commented 8 years ago

Bumping this PR, it would be useful to have metadata available for this cloudformation feature: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-interface.html

jonaf commented 8 years ago

@Carles-Figuerola Please open a new issue for adding support for the metadata interface feature, and we can link it to depend on this PR.

scarybot commented 8 years ago

I've modified the syntax as suggested, and added CloudFormation template metadata to the example script.