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

Remove region from stack_master.yml #256

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions features/apply.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
"""
Expand Down
7 changes: 3 additions & 4 deletions features/apply_with_compile_time_parameters.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Then the exit status should be 0
7 changes: 3 additions & 4 deletions features/apply_with_env_parameters.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Then the exit status should be 0
5 changes: 2 additions & 3 deletions features/apply_with_parameter_store_parameters.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions features/apply_with_s3.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions features/diff.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions features/events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion features/init.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions features/outputs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 2 additions & 6 deletions features/region_aliases.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions features/resources.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 10 additions & 12 deletions features/stack_defaults.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 7 additions & 8 deletions features/status.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 |
| ----------\|------------\|-----------------\|---------- |
Expand Down
5 changes: 2 additions & 3 deletions features/validate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 10 additions & 12 deletions lib/stack_master/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -194,24 +193,23 @@ 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
end

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?
Expand Down
2 changes: 1 addition & 1 deletion lib/stack_master/commands/compile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/stack_master/commands/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/stack_master/commands/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading