Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple aliases for a single region #221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rbayerl
Copy link
Contributor

@rbayerl rbayerl commented Mar 27, 2018

Related to #115 and #180 I have hit an issue where only the last region alias defined is actually honored. This simple patch allows for multiple aliases in a single region, but does not set any precedence for parameter resolution. E.g. consider the following:

region_aliases:
  foo: us-east-1
  bar: us-east-1

stacks:
  foo:
    foo-stack:
      template: foo.rb
  bar:
    bar-stack:
      template: bar.rb

Parameters for both stacks will look in parameters/foo and parameters/bar. Since one cannot have duplicate stack names in a region IMO this is not a huge issue. This patch will at least allow the option for logical stack_master.yml layout and ordering for parameter files.

@et304383
Copy link

et304383 commented Apr 19, 2018

@rbayerl could you try explaining the parameters issue you described in another way? I'm not sure I understand the limitation based on what you've described in your last paragraph.

@rbayerl
Copy link
Contributor Author

rbayerl commented Apr 19, 2018

Using the above example config here's what comes from irb:

irb(main):001:0> require 'stack_master'
=> true
irb(main):002:0> config = StackMaster::Config.load!('stack_master.yml')
=> #<StackMaster::Config:0x007fa261042440 @config={"template_dir"=>"./templates", "region_aliases"=>{"foo"=>"us-east-1", "bar"=>"us-east-1"}, "stacks"=>{"foo"=>{"foo-stack"=>{"template"=>"foo.rb"}}, "bar"=>{"bar-stack"=>{"template"=>"bar.rb"}}}}, @base_dir="/Users/rbayerl/foobar", @template_dir="./templates", @stack_defaults={}, @region_aliases={"foo"=>"us-east-1", "bar"=>"us-east-1"}, @region_to_aliases={"us-east-1"=>["foo", "bar"]}, @region_defaults={}, @stacks=[#<StackMaster::StackDefinition:0x007fa261029af8 @additional_parameter_lookup_dirs=["foo", "bar"], @compiler_options={}, @notification_arns=[], @s3={}, @files=[], @template="bar.rb", @region="us-east-1", @stack_name="bar-stack", @base_dir="/Users/rbayerl/foobar", @template_dir="./templates">], @template_compilers={:rb=>:sparkle_formation, :json=>:json, :yml=>:yaml, :yaml=>:yaml}>
irb(main):003:0> config.stacks[0].additional_parameter_lookup_dirs
=> ["foo", "bar"]

Since the parameter lookup directories just creates an array of all aliases these will all be included for all stacks in the region (regardless of the alias where the stack is defined). So parameters for the foo stack will look in ['parameters/foo.yml', 'parameters/us-east-1/foo.yml', 'parameters/foo/foo.yml', 'parameters/bar/foo.yml']. Hope that's at least a little more clear.

Copy link
Contributor

@patrobinson patrobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add some tests for this?

Given the age of this PR (our fault) it could also do with a rebase too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants