bazaarvoice / cloudformation-ruby-dsl

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

Add option --s3-bucket to upload templates to S3 #122

Closed jonaf closed 6 years ago

jonaf commented 6 years ago

Description

Sometimes, you just need more than 52K for a template. You can get 400K if you upload the template to S3 first. See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html

Steps to Test or Reproduce

  1. Checkout this PR.
  2. Create a bucket of your own (which you must have access to)
  3. Create a Cloudformation stack as normal, but supply the bucket name to the DSL using the --s3-bucket argument.

Example:

./my-cfn-stack.rb create MY_STACK --s3-bucket MY_BUCKET_NAME

Environment

$ uname -a
Darwin jfenocchi-r.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:13:31 PDT 2017; root:xnu-3789.60.24~4/RELEASE_X86_64 x86_64
$ ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

Deploy Notes

This change should constitute a minor version increase, as it is a net new feature.

jonaf commented 6 years ago

I discovered this prior art, where the Cloudformation CLI apparently has a "package" sub-command. http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-cli-package.html

snguyen-ith commented 6 years ago

Having issues with this latest release (v1.5.0)

tianx2 commented 6 years ago

@snguyen-ith what sort of issue are you having?

snguyen-ith commented 6 years ago

@tianx2

In my templates, I load a common mapping file.

load_from_file('path/to/common.rb')

Which has contents such as

mapping 'mapping1', "#{$common_dir}/mappings/mapping1.rb" mapping 'mapping2', "#{$common_dir}/mappings/mapping2.rb"

Each mapping file looks something like { 'Mappings' => { 'Mapping1' => { foobar: { item: 'foo' } } }

Expanding a ruby template gives me Users/snguyen/.rvm/gems/ruby-2.2.6/gems/cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/dsl.rb:118:inmapping': undefined method []' for nil:NilClass (NoMethodError) from ../../lib/common.rb:3:inload_from_file' from /Users/snguyen/.rvm/gems/ruby-2.2.6/gems/cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/dsl.rb:129:in eval' from /Users/snguyen/.rvm/gems/ruby-2.2.6/gems/cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/dsl.rb:129:inload_from_file' from ./consumer.rb:31:in block in <main>' from /Users/snguyen/.rvm/gems/ruby-2.2.6/gems/cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/dsl.rb:24:ininstance_eval' from /Users/snguyen/.rvm/gems/ruby-2.2.6/gems/cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/dsl.rb:24:in initialize' from /Users/snguyen/.rvm/gems/ruby-2.2.6/gems/cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/dsl.rb:79:ininitialize' from /Users/snguyen/.rvm/gems/ruby-2.2.6/gems/cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/dsl.rb:48:in new' from /Users/snguyen/.rvm/gems/ruby-2.2.6/gems/cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/dsl.rb:48:inraw_template' from /Users/snguyen/.rvm/gems/ruby-2.2.6/gems/cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/cfntemplate.rb:665:in template' from ./consumer.rb:29:in

' `

tianx2 commented 6 years ago

@snguyen-ith Please file an issue with this comment and I'll take a look at it.