stackr 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5400276137168449771e71adbdd0c18da5c21e0f
4
- data.tar.gz: 59e07af064f309b0b2940ea191514642e6ff71bb
3
+ metadata.gz: 102190aec51260a54c6e0d3c0963c33ea153a641
4
+ data.tar.gz: 4a6eb9fb914b0ee9517f93f0bd05c456729c8c71
5
5
  SHA512:
6
- metadata.gz: db02fba0dbceca816d2ffda2b2ed7aa6ff366210f3737194a7b9a2d7d77b4b30f249ebe97c05d7e0d0a5dc988d308e6d3821c869d3382abac36452da8d1a52f2
7
- data.tar.gz: c779134b35dff120b7237b59c431725f5eec360bf1431e02611aa63450e491495252ffec9eb8561c137f986a48a200893faa1fc35ed35e7b3b266dc4d2e457cc
6
+ metadata.gz: 395e5ca269cffc68e3a67d980a8601a534694e848783bc27801c7add3a09c14d13494bf3409b95cc8688e9cebb96e25424167036072db1fbab1dc2b2407de940
7
+ data.tar.gz: 31446b8e086d8d26eb3fe93c9b460de39a038df893706138e88f6146d34e218d29059145bf097a971594635c4501a23580ef781b018cb2c2f32915f7da02599c
data/README.md CHANGED
@@ -76,6 +76,14 @@ You can use a ```.env``` file for your environment variables. It's included in t
76
76
 
77
77
  You may want to use the same template to launch stacks in different environments (e.g. 'dev', 'prd', 'test'). You can edit ```includes/environment_map.rb``` to configure your different environments. This is useful when you are creating resources in different VPCs or Regions for different environments.
78
78
 
79
+ ### Breaking Change in Behavior for 2.0.0
80
+
81
+ In order to support mappings with greater than 64 attributes, we no longer add a mapping for ```includes/environment_map.rb``` directly in the template. Instead, we load the environment map into a lookup table and ```find_in_env``` simply returns the value it finds in that table. This greatly reduces the size if templates with very large environment maps.
82
+
83
+ If you want to use the old 1.x deprecated behavior be sure to include this line in the body of your template script and use ```find_in_env_map()``` instead of ```find_in_env()```
84
+
85
+ ```mapping 'EnvironmentMap', File.join(t.includes_path, 'environment_map.rb')```
86
+
79
87
  ## Contributing
80
88
 
81
89
  Bug reports and pull requests are welcome on GitHub at https://github.com/LeafSoftware/stackr.
@@ -24,8 +24,11 @@ module Stackr
24
24
  if ENV['TEMPLATE_BUCKET'].nil?
25
25
  raise Stackr::TemplateBucketMissingError, 'Please set TEMPLATE_BUCKET environment variable before uploading templates to S3.'
26
26
  end
27
+ if ENV['ENVIRONMENT'].nil?
28
+ raise Stackr::EnvironmentMissingError, 'Please set ENVIRONMENT environment variable before uploading templates to S3.'
29
+ end
27
30
  bucket = s3.bucket(ENV['TEMPLATE_BUCKET'])
28
- key = "#{name}.json"
31
+ key = "#{ENV['ENVIRONMENT']}/#{name}.json"
29
32
  if ENV['TEMPLATE_PREFIX']
30
33
  key = "#{ENV['TEMPLATE_PREFIX']}/#{key}"
31
34
  end
data/lib/stackr/errors.rb CHANGED
@@ -6,7 +6,8 @@ module Stackr
6
6
  class TemplateValidationError < StandardError; end
7
7
  class ParameterMissingError < StandardError; end
8
8
  class TemplateTooBigError < StandardError; end
9
- class TemplateMissingBucketError < StandardError; end
9
+ class TemplateBucketMissingError < StandardError; end
10
10
  class StackNameMissingError < StandardError; end
11
11
  class ChangeSetMissingError < StandardError; end
12
+ class EnvironmentMissingError < StandardError; end
12
13
  end
@@ -5,10 +5,30 @@ module Stackr
5
5
  # Put all helper methods that you want to add to the DSL here.
6
6
  # TODO: Make something that loads project helpers too.
7
7
 
8
- def find_in_env(name)
8
+ # DEPRECATED: This is the old version of find_in_env()
9
+ # It fails when there are more than 64 attributes in the map.
10
+ # Use new find_in_env() instead
11
+ def find_in_env_map(name)
9
12
  find_in_map('EnvironmentMap', ref('Environment'), name)
10
13
  end
11
14
 
15
+ def load_environment_map
16
+ if @environment_map.nil?
17
+ map_path = File.join(includes_path, 'environment_map.rb')
18
+ mappings = eval(File.read(map_path))
19
+ @environment_map = mappings['Mappings']['EnvironmentMap']
20
+ end
21
+ @environment_map
22
+ end
23
+
24
+ def find_in_env(name)
25
+ if ENV['ENVIRONMENT'].nil?
26
+ raise Stackr::EnvironmentMissingError, 'Please set ENVIRONMENT environment variable.'
27
+ end
28
+ map = load_environment_map()
29
+ return map[ ENV['ENVIRONMENT'].to_sym ][name.to_sym]
30
+ end
31
+
12
32
  def include_file(filepath, locals={})
13
33
  interpolate(file(filepath), locals)
14
34
  end
@@ -1,3 +1,3 @@
1
1
  module Stackr
2
- VERSION = "1.1.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -30,11 +30,6 @@ Stackr::Template.new.tap do |t|
30
30
 
31
31
  # Add other parameters here.
32
32
 
33
- # Add in the environment map in includes/environment_map.rb
34
- # You can edit the map to include environment specific things
35
- # like Vpc, Subnets, Security Groups, etc.
36
- mapping 'EnvironmentMap', File.join(t.includes_path, 'environment_map.rb')
37
-
38
33
  # Add resources here.
39
34
 
40
35
  # Add outputs here.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Chalfant
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-28 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk