diff --git a/features/apply.feature b/features/apply.feature index 2ec9e427..02219ae6 100644 --- a/features/apply.feature +++ b/features/apply.feature @@ -4,11 +4,10 @@ Feature: Apply command Given a file named "stack_master.yml" with: """ stacks: - us_east_1: - myapp_vpc: - template: myapp_vpc.rb - myapp_web: - template: myapp_web.rb + myapp_vpc: + template: myapp_vpc.rb + myapp_web: + template: myapp_web.rb """ And a directory named "parameters" And a file named "parameters/myapp_vpc.yml" with: @@ -332,12 +331,11 @@ Feature: Apply command Given a file named "stack_master.yml" with: """ stacks: - us_east_1: - myapp_vpc: - template: myapp_vpc.rb - notification_arns: - - test_arn - stack_policy_file: no_rds_replacement.json + myapp_vpc: + template: myapp_vpc.rb + notification_arns: + - test_arn + stack_policy_file: no_rds_replacement.json """ And a file named "policies/no_rds_replacement.json" with: """ diff --git a/features/apply_with_compile_time_parameters.feature b/features/apply_with_compile_time_parameters.feature index 3e71823e..0c573b8a 100644 --- a/features/apply_with_compile_time_parameters.feature +++ b/features/apply_with_compile_time_parameters.feature @@ -4,9 +4,8 @@ Feature: Apply command with compile time parameters Given a file named "stack_master.yml" with: """ stacks: - us-east-1: - vpc: - template: vpc.rb + vpc: + template: vpc.rb """ And a directory named "parameters" And a file named "parameters/vpc.yml" with: @@ -90,4 +89,4 @@ Feature: Apply command with compile time parameters | + } | | + } | And the output should match /2020-10-29 00:00:00 (\+|\-)[0-9]{4} vpc AWS::CloudFormation::Stack CREATE_COMPLETE/ - Then the exit status should be 0 \ No newline at end of file + Then the exit status should be 0 diff --git a/features/apply_with_env_parameters.feature b/features/apply_with_env_parameters.feature index 921532ef..e930fa62 100644 --- a/features/apply_with_env_parameters.feature +++ b/features/apply_with_env_parameters.feature @@ -4,9 +4,8 @@ Feature: Apply command with environment parameter Given a file named "stack_master.yml" with: """ stacks: - us-east-2: - vpc: - template: vpc.rb + vpc: + template: vpc.rb """ And a directory named "parameters" And a file named "parameters/vpc.yml" with: @@ -46,4 +45,4 @@ Feature: Apply command with environment parameter | +--- | | +VpcCidr: 10.0.0.0/16 | And the output should match /2020-10-29 00:00:00 (\+|\-)[0-9]{4} vpc AWS::CloudFormation::Stack CREATE_COMPLETE/ - Then the exit status should be 0 \ No newline at end of file + Then the exit status should be 0 diff --git a/features/apply_with_parameter_store_parameters.feature b/features/apply_with_parameter_store_parameters.feature index 9eb1f96a..8340b245 100644 --- a/features/apply_with_parameter_store_parameters.feature +++ b/features/apply_with_parameter_store_parameters.feature @@ -4,9 +4,8 @@ Feature: Apply command with parameter_store parameter Given a file named "stack_master.yml" with: """ stacks: - us-east-2: - vpc: - template: vpc.rb + vpc: + template: vpc.rb """ And a directory named "parameters" And a file named "parameters/vpc.yml" with: diff --git a/features/apply_with_s3.feature b/features/apply_with_s3.feature index 5f957b25..994d5f70 100644 --- a/features/apply_with_s3.feature +++ b/features/apply_with_s3.feature @@ -9,11 +9,10 @@ Feature: Apply command region: us-east-1 prefix: cfn_templates/my-app stacks: - us_east_1: - myapp_vpc: - template: myapp_vpc.rb - files: - - user_data.sh + myapp_vpc: + template: myapp_vpc.rb + files: + - user_data.sh """ And a directory named "parameters" And a file named "parameters/myapp_vpc.yml" with: diff --git a/features/diff.feature b/features/diff.feature index a7c29d0c..1a462a10 100644 --- a/features/diff.feature +++ b/features/diff.feature @@ -4,9 +4,8 @@ Feature: Diff command Given a file named "stack_master.yml" with: """ stacks: - us_east_1: - myapp_vpc: - template: myapp_vpc.json + myapp_vpc: + template: myapp_vpc.json """ And a directory named "parameters" And a file named "parameters/myapp_vpc.yml" with: diff --git a/features/events.feature b/features/events.feature index 3f26ddcd..2760f950 100644 --- a/features/events.feature +++ b/features/events.feature @@ -4,9 +4,8 @@ Feature: Events command Given a file named "stack_master.yml" with: """ stacks: - us_east_1: - myapp_vpc: - template: myapp_vpc.rb + myapp_vpc: + template: myapp_vpc.rb """ And a directory named "templates" And a file named "templates/myapp_vpc.rb" with: diff --git a/features/init.feature b/features/init.feature index 27fb20e8..45899b52 100644 --- a/features/init.feature +++ b/features/init.feature @@ -2,5 +2,4 @@ Feature: init project Scenario: Run init When I run `stack_master init us-east-1 my-app` - # TODO flesh this out Then the exit status should be 0 diff --git a/features/outputs.feature b/features/outputs.feature index c4aa3a33..3dec804d 100644 --- a/features/outputs.feature +++ b/features/outputs.feature @@ -4,9 +4,8 @@ Feature: Outputs command Given a file named "stack_master.yml" with: """ stacks: - us_east_1: - myapp_vpc: - template: myapp_vpc.rb + myapp_vpc: + template: myapp_vpc.rb """ And a directory named "templates" And a file named "templates/myapp_vpc.rb" with: diff --git a/features/region_aliases.feature b/features/region_aliases.feature index bc789bb6..02a6bec9 100644 --- a/features/region_aliases.feature +++ b/features/region_aliases.feature @@ -7,12 +7,8 @@ Feature: Region aliases staging: ap-southeast-2 production: us_east_1 stacks: - staging: - myapp_vpc: - template: myapp_vpc.rb - production: - myapp_vpc: - template: myapp_vpc.rb + myapp_vpc: + template: myapp_vpc.rb """ And a directory named "templates" And a directory named "parameters" diff --git a/features/resources.feature b/features/resources.feature index 113e2664..b5b5a7f1 100644 --- a/features/resources.feature +++ b/features/resources.feature @@ -4,9 +4,8 @@ Feature: Resources command Given a file named "stack_master.yml" with: """ stacks: - us_east_1: - myapp_vpc: - template: myapp_vpc.rb + myapp_vpc: + template: myapp_vpc.rb """ And a directory named "templates" And a file named "templates/myapp_vpc.rb" with: diff --git a/features/stack_defaults.feature b/features/stack_defaults.feature index dc9b26ab..25006aff 100644 --- a/features/stack_defaults.feature +++ b/features/stack_defaults.feature @@ -21,18 +21,16 @@ Feature: Stack defaults tags: environment: production stacks: - ap_southeast_2: - myapp_vpc: - template: myapp_vpc.rb - tags: - role: network - notification_arns: - - test_arn_3 - us_east_1: - myapp_vpc: - template: myapp_vpc.rb - tags: - role: network + myapp_vpc: + template: myapp_vpc.rb + tags: + role: network + notification_arns: + - test_arn_3 + myotherapp_vpc: + template: myapp_vpc.rb + tags: + role: network """ And a directory named "templates" And a directory named "policies" diff --git a/features/status.feature b/features/status.feature index 0c307560..797972d1 100644 --- a/features/status.feature +++ b/features/status.feature @@ -4,13 +4,12 @@ Feature: Status command Given a file named "stack_master.yml" with: """ stacks: - us_east_1: - stack1: - template: stack1.json - stack2: - template: stack2.json - stack3: - template: stack3.json + stack1: + template: stack1.json + stack2: + template: stack2.json + stack3: + template: stack3.json """ And a directory named "parameters" And a file named "parameters/stack1.yml" with: @@ -106,7 +105,7 @@ Feature: Status command } """ - When I run `stack_master status --trace` + When I run `stack_master status us-east-1 --trace` And the output should contain all of these lines: | REGION \| STACK_NAME \| STACK_STATUS \| DIFFERENT | | ----------\|------------\|-----------------\|---------- | diff --git a/features/validate.feature b/features/validate.feature index 7da935d7..7f9b12e5 100644 --- a/features/validate.feature +++ b/features/validate.feature @@ -4,9 +4,8 @@ Feature: Validate command Given a file named "stack_master.yml" with: """ stacks: - us_east_1: - stack1: - template: stack1.json + stack1: + template: stack1.json """ And a directory named "parameters" And a file named "parameters/stack1.yml" with: diff --git a/lib/stack_master/cli.rb b/lib/stack_master/cli.rb index c646b4db..71524242 100644 --- a/lib/stack_master/cli.rb +++ b/lib/stack_master/cli.rb @@ -115,7 +115,7 @@ def execute! c.action do |args, options| options.defaults config: default_config_file say "Invalid arguments." if args.size > 0 - config = load_config(options.config) + config = load_config(options.config, 'us-east-1') StackMaster::Commands::ListStacks.perform(config) end end @@ -154,14 +154,13 @@ def execute! end command :status do |c| - c.syntax = 'stack_master status' + c.syntax = 'stack_master status [region]' c.summary = 'Check the current status stacks.' c.description = 'Checks the status of all stacks defined in the stack_master.yml file. Warning this operation can be somewhat slow.' c.example 'description', 'Check the status of all stack definitions' c.action do |args, options| options.defaults config: default_config_file - say "Invalid arguments. stack_master status" and return unless args.size == 0 - config = load_config(options.config) + config = load_config(options.config, args[0]) StackMaster::Commands::Status.perform(config) end end @@ -180,8 +179,8 @@ def execute! # Because delete can work without a stack_master.yml if options.config and File.file?(options.config) - config = load_config(options.config) - region = Utils.underscore_to_hyphen(config.unalias_region(args[0])) + config = load_config(options.config, args[0]) + region = config.region else region = args[0] end @@ -194,9 +193,9 @@ def execute! run! end - def load_config(file) + def load_config(file, region) stack_file = file || default_config_file - StackMaster::Config.load!(stack_file) + StackMaster::Config.load!(stack_file, region) rescue Errno::ENOENT => e say "Failed to load config file #{stack_file}" exit 1 @@ -204,14 +203,13 @@ def load_config(file) def execute_stacks_command(command, args, options) command_results = [] - config = load_config(options.config) + config = load_config(options.config, args[0]) args = [nil, nil] if args.size == 0 args.each_slice(2) do |aliased_region, stack_name| - region = Utils.underscore_to_hyphen(config.unalias_region(aliased_region)) stack_name = Utils.underscore_to_hyphen(stack_name) - stack_definitions = config.filter(region, stack_name) + stack_definitions = config.filter(stack_name) if stack_definitions.empty? - StackMaster.stdout.puts "Could not find stack definition #{stack_name} in region #{region}" + StackMaster.stdout.puts "Could not find stack definition #{stack_name}" end stack_definitions = stack_definitions.select do |stack_definition| StackStatus.new(config, stack_definition).changed? diff --git a/lib/stack_master/commands/compile.rb b/lib/stack_master/commands/compile.rb index caaf79cb..0f94726a 100644 --- a/lib/stack_master/commands/compile.rb +++ b/lib/stack_master/commands/compile.rb @@ -16,7 +16,7 @@ def perform private def stack_definition - @stack_definition ||= @config.find_stack(@region, @stack_name) + @stack_definition ||= @config.find_stack(@stack_name) end def proposed_stack diff --git a/lib/stack_master/commands/diff.rb b/lib/stack_master/commands/diff.rb index 48bd4827..668814d7 100644 --- a/lib/stack_master/commands/diff.rb +++ b/lib/stack_master/commands/diff.rb @@ -16,7 +16,7 @@ def perform private def stack_definition - @stack_definition ||= @config.find_stack(@region, @stack_name) + @stack_definition ||= @config.find_stack(@stack_name) end def stack diff --git a/lib/stack_master/commands/lint.rb b/lib/stack_master/commands/lint.rb index 0ab868ea..74621491 100644 --- a/lib/stack_master/commands/lint.rb +++ b/lib/stack_master/commands/lint.rb @@ -27,7 +27,7 @@ def perform private def stack_definition - @stack_definition ||= @config.find_stack(@region, @stack_name) + @stack_definition ||= @config.find_stack(@stack_name) end def proposed_stack diff --git a/lib/stack_master/config.rb b/lib/stack_master/config.rb index 5e46eda2..c18516c4 100644 --- a/lib/stack_master/config.rb +++ b/lib/stack_master/config.rb @@ -5,11 +5,11 @@ module StackMaster class Config ConfigParseError = Class.new(StandardError) - def self.load!(config_file = 'stack_master.yml') + def self.load!(config_file = 'stack_master.yml', region) resolved_config_file = search_up_and_chdir(config_file) config = YAML.load(File.read(resolved_config_file)) base_dir = File.dirname(File.expand_path(resolved_config_file)) - new(config, base_dir) + new(config, base_dir, region) rescue Psych::SyntaxError => error raise ConfigParseError, "Unable to parse #{resolved_config_file}: #{error}" end @@ -21,6 +21,7 @@ def self.load!(config_file = 'stack_master.yml') :region_defaults, :region_aliases, :template_compilers, + :region, def self.search_up_and_chdir(config_file) return config_file unless File.dirname(config_file) == "." @@ -35,7 +36,7 @@ def self.search_up_and_chdir(config_file) File.join(dir, config_file) end - def initialize(config, base_dir) + def initialize(config, base_dir, unaliased_region) @config = config @base_dir = base_dir @template_dir = config.fetch('template_dir', nil) @@ -46,21 +47,22 @@ def initialize(config, base_dir) hash[value] << key hash end + @region = unalias_region(unaliased_region) @region_defaults = normalise_region_defaults(config.fetch('region_defaults', {})) @stacks = [] load_template_compilers(config) load_config end - def filter(region = nil, stack_name = nil) + def filter(stack_name = nil) @stacks.select do |s| - (region.blank? || s.region == region || s.region == region.gsub('_', '-')) && + (@region.blank? || s.region == @region || s.region == @region.gsub('_', '-')) && (stack_name.blank? || s.stack_name == stack_name || s.stack_name == stack_name.gsub('_', '-')) end end - def find_stack(region, stack_name) - filter(region, stack_name).first + def find_stack(stack_name) + filter(stack_name).first end def unalias_region(region) @@ -94,24 +96,14 @@ def default_template_compilers end def load_config - unaliased_stacks = resolve_region_aliases(@config.fetch('stacks')) - load_stacks(unaliased_stacks) - end - - def resolve_region_aliases(stacks) - stacks.inject({}) do |hash, (region, attributes)| - hash[unalias_region(region)] = attributes - hash - end + load_stacks(@config.fetch('stacks')) end def load_stacks(stacks) - stacks.each do |region, stacks_for_region| - region = Utils.underscore_to_hyphen(region) - stacks_for_region.each do |stack_name, attributes| + stacks.each do |stack_name, attributes| stack_name = Utils.underscore_to_hyphen(stack_name) - stack_attributes = build_stack_defaults(region).deeper_merge!(attributes).merge( - 'region' => region, + stack_attributes = build_stack_defaults(@region).deeper_merge!(attributes).merge( + 'region' => @region, 'stack_name' => stack_name, 'base_dir' => @base_dir, 'template_dir' => @template_dir, @@ -119,7 +111,6 @@ def load_stacks(stacks) @stacks << StackDefinition.new(stack_attributes) end end - end def build_stack_defaults(region) region_defaults = @region_defaults.fetch(region, {}).deep_dup diff --git a/lib/stack_master/utils.rb b/lib/stack_master/utils.rb index 2149bee6..b40ae132 100644 --- a/lib/stack_master/utils.rb +++ b/lib/stack_master/utils.rb @@ -22,9 +22,9 @@ def change_extension(file_name, extension) end def hash_to_aws_parameters(params) - params.inject([]) do |params, (key, value)| - params << { parameter_key: key, parameter_value: value } - params + params.inject([]) do |aws_params, (key, value)| + aws_params << { parameter_key: key, parameter_value: value } + aws_params end end @@ -41,9 +41,9 @@ def underscore_to_hyphen(string) end def underscore_keys_to_hyphen(hash) - hash.inject({}) do |hash, (key, value)| - hash[underscore_to_hyphen(key)] = value - hash + hash.inject({}) do |hash_with_underscore_keys, (key, value)| + hash_with_underscore_keys[underscore_to_hyphen(key)] = value + hash_with_underscore_keys end end end diff --git a/spec/fixtures/stack_master.yml b/spec/fixtures/stack_master.yml index 286a539e..fdf3577a 100644 --- a/spec/fixtures/stack_master.yml +++ b/spec/fixtures/stack_master.yml @@ -4,9 +4,6 @@ region_aliases: stack_defaults: tags: application: my-awesome-blog - s3: - bucket: my-bucket - region: us-east-1 template_compilers: rb: ruby_dsl region_defaults: @@ -18,6 +15,9 @@ region_defaults: role_arn: test_service_role_arn secret_file: production.yml.gpg stack_policy_file: my_policy.json + s3: + bucket: my-bucket + region: us-east-1 staging: tags: environment: staging @@ -26,24 +26,25 @@ region_defaults: - test_arn_3 role_arn: test_service_role_arn3 secret_file: staging.yml.gpg + s3: + bucket: my-bucket + region: ap-southeast-2 stacks: - us-east-1: - myapp_vpc: - template: myapp_vpc.json - notification_arns: - - test_arn_2 - role_arn: test_service_role_arn2 - myapp_web: - template: myapp_web.rb - myapp_vpc_with_secrets: - template: myapp_vpc.json - ap-southeast-2: - myapp_vpc: - template: myapp_vpc.rb - notification_arns: - - test_arn_4 - role_arn: test_service_role_arn4 - myapp_web: - template: myapp_web - tags: - test_override: 2 + myapp_vpc: + template: myapp_vpc.json + notification_arns: + - test_arn_2 + role_arn: test_service_role_arn2 + myapp_web: + template: myapp_web.rb + myapp_vpc_with_secrets: + template: myapp_vpc.json + myotherapp_vpc: + template: myapp_vpc.rb + notification_arns: + - test_arn_4 + role_arn: test_service_role_arn4 + myotherapp_web: + template: myapp_web + tags: + test_override: 2 diff --git a/spec/stack_master/config_spec.rb b/spec/stack_master/config_spec.rb index 0e1e8c40..4a37be36 100644 --- a/spec/stack_master/config_spec.rb +++ b/spec/stack_master/config_spec.rb @@ -1,9 +1,10 @@ RSpec.describe StackMaster::Config do - subject(:loaded_config) { StackMaster::Config.load!('spec/fixtures/stack_master.yml') } + let(:region) { 'us-east-1' } + subject(:loaded_config) { StackMaster::Config.load!('spec/fixtures/stack_master.yml', region) } let(:base_dir) { File.expand_path('spec/fixtures') } let(:myapp_vpc_definition) { StackMaster::StackDefinition.new( - region: 'us-east-1', + region: region, region_alias: 'production', stack_name: 'myapp-vpc', template: 'myapp_vpc.json', @@ -48,27 +49,22 @@ describe '#find_stack' do it 'returns an object that can find stack definitions' do - stack = loaded_config.find_stack('us-east-1', 'myapp-vpc') + stack = loaded_config.find_stack('myapp-vpc') expect(stack).to eq(myapp_vpc_definition) end it 'can find things with underscores instead of hyphens' do - stack = loaded_config.find_stack('us_east_1', 'myapp_vpc') + stack = loaded_config.find_stack('myapp_vpc') expect(stack).to eq(myapp_vpc_definition) end end describe '#filter' do it 'returns a list of stack definitions' do - stack = loaded_config.filter('us-east-1', 'myapp-vpc') + stack = loaded_config.filter('myapp-vpc') expect(stack).to eq([myapp_vpc_definition]) end - it 'can filter by region only' do - stacks = loaded_config.filter('us-east-1') - expect(stacks.size).to eq 3 - end - it 'can return all stack definitions with no filters' do stacks = loaded_config.filter expect(stacks.size).to eq 5 @@ -82,7 +78,6 @@ it 'loads stack defaults' do expect(loaded_config.stack_defaults).to eq({ 'tags' => { 'application' => 'my-awesome-blog' }, - 's3' => { 'bucket' => 'my-bucket', 'region' => 'us-east-1' } }) end @@ -103,13 +98,15 @@ 'role_arn' => 'test_service_role_arn', 'notification_arns' => ['test_arn'], 'secret_file' => 'production.yml.gpg', - 'stack_policy_file' => 'my_policy.json' + 'stack_policy_file' => 'my_policy.json', + 's3' => { 'bucket' => 'my-bucket', 'region' => 'us-east-1'} }, 'ap-southeast-2' => { 'tags' => {'environment' => 'staging', 'test_override' => 1 }, 'role_arn' => 'test_service_role_arn3', 'notification_arns' => ['test_arn_3'], - 'secret_file' => 'staging.yml.gpg' + 'secret_file' => 'staging.yml.gpg', + 's3' => { 'bucket' => 'my-bucket', 'region' => 'ap-southeast-2' } } }) end @@ -121,45 +118,46 @@ ) end - it 'deep merges stack attributes' do - expect(loaded_config.find_stack('ap-southeast-2', 'myapp-vpc')).to eq(StackMaster::StackDefinition.new( - stack_name: 'myapp-vpc', - region: 'ap-southeast-2', - region_alias: 'staging', - tags: { - 'application' => 'my-awesome-blog', - 'environment' => 'staging', - 'test_override' => 1 - }, - s3: { 'bucket' => 'my-bucket', 'region' => 'us-east-1' }, - role_arn: 'test_service_role_arn4', - notification_arns: ['test_arn_3', 'test_arn_4'], - template: 'myapp_vpc.rb', - base_dir: base_dir, - secret_file: 'staging.yml.gpg', - additional_parameter_lookup_dirs: ['staging'] - )) - expect(loaded_config.find_stack('ap-southeast-2', 'myapp-web')).to eq(StackMaster::StackDefinition.new( - stack_name: 'myapp-web', - region: 'ap-southeast-2', - region_alias: 'staging', - tags: { - 'application' => 'my-awesome-blog', - 'environment' => 'staging', - 'test_override' => 2 - }, - s3: { 'bucket' => 'my-bucket', 'region' => 'us-east-1' }, - role_arn: 'test_service_role_arn3', - notification_arns: ['test_arn_3'], - template: 'myapp_web', - base_dir: base_dir, - secret_file: 'staging.yml.gpg', - additional_parameter_lookup_dirs: ['staging'] - )) + context 'in the staging environment' do + let(:region) { 'staging' } + it 'deep merges stack attributes' do + expect(loaded_config.find_stack('myotherapp-vpc')).to eq(StackMaster::StackDefinition.new( + stack_name: 'myotherapp-vpc', + region: 'ap-southeast-2', + tags: { + 'application' => 'my-awesome-blog', + 'environment' => 'staging', + 'test_override' => 1 + }, + s3: { 'bucket' => 'my-bucket', 'region' => 'ap-southeast-2' }, + role_arn: 'test_service_role_arn4', + notification_arns: ['test_arn_3', 'test_arn_4'], + template: 'myapp_vpc.rb', + base_dir: base_dir, + secret_file: 'staging.yml.gpg', + additional_parameter_lookup_dirs: ['staging'] + )) + expect(loaded_config.find_stack('myotherapp-web')).to eq(StackMaster::StackDefinition.new( + stack_name: 'myotherapp-web', + region: 'ap-southeast-2', + tags: { + 'application' => 'my-awesome-blog', + 'environment' => 'staging', + 'test_override' => 2 + }, + s3: { 'bucket' => 'my-bucket', 'region' => 'ap-southeast-2' }, + role_arn: 'test_service_role_arn3', + notification_arns: ['test_arn_3'], + template: 'myapp_web', + base_dir: base_dir, + secret_file: 'staging.yml.gpg', + additional_parameter_lookup_dirs: ['staging'] + )) + end end it 'allows region aliases in region defaults' do - config = StackMaster::Config.new({'region_aliases' => { 'production' => 'us-east-1' }, 'region_defaults' => { 'production' => { 'secret_file' => 'production.yml.gpg' }}, 'stacks' => {}}, '/base') + config = StackMaster::Config.new({'region_aliases' => { 'production' => 'us-east-1' }, 'region_defaults' => { 'production' => { 'secret_file' => 'production.yml.gpg' }}, 'stacks' => {}}, '/base', 'us-east-1') expect(config.region_defaults).to eq('us-east-1' => { 'secret_file' => 'production.yml.gpg' }) end end diff --git a/spec/stack_master/stack_spec.rb b/spec/stack_master/stack_spec.rb index c26c5226..18ece854 100644 --- a/spec/stack_master/stack_spec.rb +++ b/spec/stack_master/stack_spec.rb @@ -75,7 +75,7 @@ describe '.generate' do let(:tags) { {'tag1' => 'value1'} } let(:stack_definition) { StackMaster::StackDefinition.new(region: region, stack_name: stack_name, tags: tags, base_dir: '/base_dir', template: template_file_name, notification_arns: ['test_arn'], role_arn: 'test_service_role_arn', stack_policy_file: 'no_replace_rds.json') } - let(:config) { StackMaster::Config.new({'stacks' => {}}, '/base_dir') } + let(:config) { StackMaster::Config.new({'stacks' => {}}, '/base_dir', region) } subject(:stack) { StackMaster::Stack.generate(stack_definition, config) } let(:parameter_hash) { {template_parameters: {'DbPassword' => {'secret' => 'db_password'}}, compile_time_parameters: {}} } let(:resolved_template_parameters) { {'DbPassword' => 'sdfgjkdhlfjkghdflkjghdflkjg', 'InstanceType' => 't2.medium'} } diff --git a/spec/stack_master/validator_spec.rb b/spec/stack_master/validator_spec.rb index 39f78ca8..c9694334 100644 --- a/spec/stack_master/validator_spec.rb +++ b/spec/stack_master/validator_spec.rb @@ -1,11 +1,12 @@ RSpec.describe StackMaster::Validator do subject(:validator) { described_class.new(stack_definition, config) } - let(:config) { StackMaster::Config.new({'stacks' => {}}, '/base_dir') } + let(:region) { 'us-east-1' } + let(:config) { StackMaster::Config.new({'stacks' => {}}, '/base_dir', region) } let(:stack_name) { 'myapp_vpc' } let(:stack_definition) do StackMaster::StackDefinition.new( - region: 'us-east-1', + region: region, stack_name: stack_name, template: 'myapp_vpc.json', tags: {'environment' => 'production'},