stack_master 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +22 -0
- data/README.md +12 -12
- data/lib/stack_master/cli.rb +13 -12
- data/lib/stack_master/commands/validate.rb +1 -1
- data/lib/stack_master/stack.rb +19 -0
- data/lib/stack_master/validator.rb +14 -5
- data/lib/stack_master/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb7f5a24127477671e8e06a522daedc090735825f9911168123d0a7173bf2350
|
4
|
+
data.tar.gz: 2301be2eaf943e22f980c07b75686d5303a77e3475c34f9de0eee1e6654a9bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59a9b3bc3d11e90bd4a01c57b76085bc2b702c3c10feee855d66cf3199225068a9298ff7e750dea12fdd55746e91e5b61f673065ebc48b59f22e1d2344c1c6f9
|
7
|
+
data.tar.gz: bdef690c7b5ea589d060f92c8c09a9fb4f491216ed2997a2c37f3c67bea41a598d70039686a17d44efa26d03e8cc17786ce5a424efd9d41f659af370ee98f8ed
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Steve Hodgkiss
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ Stacks are defined inside a `stack_master.yml` YAML file. When running
|
|
53
53
|
directory, or that the file is passed in with `--config
|
54
54
|
/path/to/stack_master.yml`. Here's an example configuration file:
|
55
55
|
|
56
|
-
```
|
56
|
+
```yaml
|
57
57
|
region_aliases:
|
58
58
|
production: us-east-1
|
59
59
|
staging: ap-southeast-2
|
@@ -166,7 +166,7 @@ Parameters are loaded from multiple YAML files, merged from the following lookup
|
|
166
166
|
|
167
167
|
A simple parameter file could look like this:
|
168
168
|
|
169
|
-
```
|
169
|
+
```yaml
|
170
170
|
key_name: myapp-us-east-1
|
171
171
|
```
|
172
172
|
|
@@ -177,7 +177,7 @@ allows you to use the [Compile Time Parameters](http://www.sparkleformation.io/d
|
|
177
177
|
|
178
178
|
A simple example looks like this
|
179
179
|
|
180
|
-
```
|
180
|
+
```yaml
|
181
181
|
vpc_cidr: 10.0.0.0/16
|
182
182
|
compile_time_parameters:
|
183
183
|
subnet_cidrs:
|
@@ -286,8 +286,8 @@ db_password:
|
|
286
286
|
An alternative to the secrets store is accessing 1password secrets using the 1password cli (`op`).
|
287
287
|
You declare a 1password lookup with the following parameters in your parameters file:
|
288
288
|
|
289
|
-
```
|
290
|
-
parameters/database.yml
|
289
|
+
```yaml
|
290
|
+
# parameters/database.yml
|
291
291
|
database_password:
|
292
292
|
one_password:
|
293
293
|
title: production database
|
@@ -477,7 +477,7 @@ name of the original resolver.
|
|
477
477
|
|
478
478
|
When creating a new resolver, one can automatically create the array resolver by adding a `array_resolver` statement
|
479
479
|
in the class definition, with an optional class name if different from the default one.
|
480
|
-
```
|
480
|
+
```ruby
|
481
481
|
module StackMaster
|
482
482
|
module ParameterResolvers
|
483
483
|
class MyResolver < Resolver
|
@@ -488,7 +488,7 @@ module StackMaster
|
|
488
488
|
end
|
489
489
|
```
|
490
490
|
In that example, using the array resolver would look like:
|
491
|
-
```
|
491
|
+
```yaml
|
492
492
|
my_parameter:
|
493
493
|
my_custom_array_resolver:
|
494
494
|
- value1
|
@@ -498,13 +498,13 @@ my_parameter:
|
|
498
498
|
Array parameter values can include nested parameter resolvers.
|
499
499
|
|
500
500
|
For example, given the following parameter definition:
|
501
|
-
```
|
501
|
+
```yaml
|
502
502
|
my_parameter:
|
503
503
|
- stack_output: my-stack/output # value resolves to 'value1'
|
504
504
|
- value2
|
505
505
|
```
|
506
506
|
The parameter value will resolve to:
|
507
|
-
```
|
507
|
+
```yaml
|
508
508
|
my_parameter: 'value1,value2'
|
509
509
|
```
|
510
510
|
|
@@ -520,7 +520,7 @@ ROLE=<%= role %>
|
|
520
520
|
|
521
521
|
And used like this in SparkleFormation templates:
|
522
522
|
|
523
|
-
```
|
523
|
+
```ruby
|
524
524
|
# templates/app.rb
|
525
525
|
user_data user_data_file!('app.erb', role: :worker)
|
526
526
|
```
|
@@ -533,7 +533,7 @@ my_variable=<%= ref!(:foo) %>
|
|
533
533
|
my_other_variable=<%= account_id! %>
|
534
534
|
```
|
535
535
|
|
536
|
-
```
|
536
|
+
```ruby
|
537
537
|
# templates/ecs_task.rb
|
538
538
|
container_definitions array!(
|
539
539
|
-> {
|
@@ -565,7 +565,7 @@ project-root
|
|
565
565
|
|
566
566
|
Your env-1/stack_master.yml files can reference common templates by setting:
|
567
567
|
|
568
|
-
```
|
568
|
+
```yaml
|
569
569
|
template_dir: ../../sparkle/templates
|
570
570
|
stack_defaults:
|
571
571
|
compiler_options:
|
data/lib/stack_master/cli.rb
CHANGED
@@ -46,7 +46,7 @@ module StackMaster
|
|
46
46
|
c.option '--on-failure ACTION', String, "Action to take on CREATE_FAILURE. Valid Values: [ DO_NOTHING | ROLLBACK | DELETE ]. Default: ROLLBACK\nNote: You cannot use this option with Serverless Application Model (SAM) templates."
|
47
47
|
c.option '--yes-param PARAM_NAME', String, "Auto-approve stack updates when only parameter PARAM_NAME changes"
|
48
48
|
c.action do |args, options|
|
49
|
-
options.
|
49
|
+
options.default config: default_config_file
|
50
50
|
execute_stacks_command(StackMaster::Commands::Apply, args, options)
|
51
51
|
end
|
52
52
|
end
|
@@ -56,7 +56,7 @@ module StackMaster
|
|
56
56
|
c.summary = 'Displays outputs for a stack'
|
57
57
|
c.description = "Displays outputs for a stack"
|
58
58
|
c.action do |args, options|
|
59
|
-
options.
|
59
|
+
options.default config: default_config_file
|
60
60
|
execute_stacks_command(StackMaster::Commands::Outputs, args, options)
|
61
61
|
end
|
62
62
|
end
|
@@ -67,7 +67,7 @@ module StackMaster
|
|
67
67
|
c.description = 'Initialises the expected directory structure and stack_master.yml file'
|
68
68
|
c.option('--overwrite', 'Overwrite existing files')
|
69
69
|
c.action do |args, options|
|
70
|
-
options.
|
70
|
+
options.default config: default_config_file
|
71
71
|
unless args.size == 2
|
72
72
|
say "Invalid arguments. stack_master init [region] [stack_name]"
|
73
73
|
else
|
@@ -82,7 +82,7 @@ module StackMaster
|
|
82
82
|
c.description = "Shows a diff of the proposed stack's template and parameters"
|
83
83
|
c.example 'diff a stack named myapp-vpc in us-east-1', 'stack_master diff us-east-1 myapp-vpc'
|
84
84
|
c.action do |args, options|
|
85
|
-
options.
|
85
|
+
options.default config: default_config_file
|
86
86
|
execute_stacks_command(StackMaster::Commands::Diff, args, options)
|
87
87
|
end
|
88
88
|
end
|
@@ -96,7 +96,7 @@ module StackMaster
|
|
96
96
|
c.option '--all', 'Show all events'
|
97
97
|
c.option '--tail', 'Tail events'
|
98
98
|
c.action do |args, options|
|
99
|
-
options.
|
99
|
+
options.default config: default_config_file
|
100
100
|
execute_stacks_command(StackMaster::Commands::Events, args, options)
|
101
101
|
end
|
102
102
|
end
|
@@ -106,7 +106,7 @@ module StackMaster
|
|
106
106
|
c.summary = "Shows stack resources"
|
107
107
|
c.description = "Shows stack resources"
|
108
108
|
c.action do |args, options|
|
109
|
-
options.
|
109
|
+
options.default config: default_config_file
|
110
110
|
execute_stacks_command(StackMaster::Commands::Resources, args, options)
|
111
111
|
end
|
112
112
|
end
|
@@ -116,7 +116,7 @@ module StackMaster
|
|
116
116
|
c.summary = 'List stack definitions'
|
117
117
|
c.description = 'List stack definitions'
|
118
118
|
c.action do |args, options|
|
119
|
-
options.
|
119
|
+
options.default config: default_config_file
|
120
120
|
say "Invalid arguments." if args.size > 0
|
121
121
|
config = load_config(options.config)
|
122
122
|
StackMaster::Commands::ListStacks.perform(config, nil, options)
|
@@ -128,8 +128,9 @@ module StackMaster
|
|
128
128
|
c.summary = 'Validate a template'
|
129
129
|
c.description = 'Validate a template'
|
130
130
|
c.example 'validate a stack named myapp-vpc in us-east-1', 'stack_master validate us-east-1 myapp-vpc'
|
131
|
+
c.option '--[no-]validate-template-parameters', 'Validate template parameters. Default: validate'
|
131
132
|
c.action do |args, options|
|
132
|
-
options.
|
133
|
+
options.default config: default_config_file, validate_template_parameters: true
|
133
134
|
execute_stacks_command(StackMaster::Commands::Validate, args, options)
|
134
135
|
end
|
135
136
|
end
|
@@ -140,7 +141,7 @@ module StackMaster
|
|
140
141
|
c.description = "Runs cfn-lint on the template which would be sent to AWS on apply"
|
141
142
|
c.example 'run cfn-lint on stack myapp-vpc with us-east-1 settings', 'stack_master lint us-east-1 myapp-vpc'
|
142
143
|
c.action do |args, options|
|
143
|
-
options.
|
144
|
+
options.default config: default_config_file
|
144
145
|
execute_stacks_command(StackMaster::Commands::Lint, args, options)
|
145
146
|
end
|
146
147
|
end
|
@@ -151,7 +152,7 @@ module StackMaster
|
|
151
152
|
c.description = "Processes the stack and prints out a compiled version - same we'd send to AWS"
|
152
153
|
c.example 'print compiled stack myapp-vpc with us-east-1 settings', 'stack_master compile us-east-1 myapp-vpc'
|
153
154
|
c.action do |args, options|
|
154
|
-
options.
|
155
|
+
options.default config: default_config_file
|
155
156
|
execute_stacks_command(StackMaster::Commands::Compile, args, options)
|
156
157
|
end
|
157
158
|
end
|
@@ -162,7 +163,7 @@ module StackMaster
|
|
162
163
|
c.description = 'Checks the status of all stacks defined in the stack_master.yml file. Warning this operation can be somewhat slow.'
|
163
164
|
c.example 'description', 'Check the status of all stack definitions'
|
164
165
|
c.action do |args, options|
|
165
|
-
options.
|
166
|
+
options.default config: default_config_file
|
166
167
|
say "Invalid arguments. stack_master status" and return unless args.size == 0
|
167
168
|
config = load_config(options.config)
|
168
169
|
StackMaster::Commands::Status.perform(config, nil, options)
|
@@ -175,7 +176,7 @@ module StackMaster
|
|
175
176
|
c.description = 'Cross references stack_master.yml with the template and parameter directories to identify extra or missing files.'
|
176
177
|
c.example 'description', 'Check for missing or extra files'
|
177
178
|
c.action do |args, options|
|
178
|
-
options.
|
179
|
+
options.default config: default_config_file
|
179
180
|
say "Invalid arguments. stack_master tidy" and return unless args.size == 0
|
180
181
|
config = load_config(options.config)
|
181
182
|
StackMaster::Commands::Tidy.perform(config, nil, options)
|
data/lib/stack_master/stack.rb
CHANGED
@@ -75,6 +75,25 @@ module StackMaster
|
|
75
75
|
stack_policy_body: stack_policy_body)
|
76
76
|
end
|
77
77
|
|
78
|
+
def self.generate_without_parameters(stack_definition, config)
|
79
|
+
parameter_hash = ParameterLoader.load(stack_definition.parameter_files)
|
80
|
+
compile_time_parameters = ParameterResolver.resolve(config, stack_definition, parameter_hash[:compile_time_parameters])
|
81
|
+
template_body = TemplateCompiler.compile(config, stack_definition.compiler, stack_definition.template_dir, stack_definition.template, compile_time_parameters, stack_definition.compiler_options)
|
82
|
+
template_format = TemplateUtils.identify_template_format(template_body)
|
83
|
+
stack_policy_body = if stack_definition.stack_policy_file_path
|
84
|
+
File.read(stack_definition.stack_policy_file_path)
|
85
|
+
end
|
86
|
+
new(region: stack_definition.region,
|
87
|
+
stack_name: stack_definition.stack_name,
|
88
|
+
tags: stack_definition.tags,
|
89
|
+
parameters: {},
|
90
|
+
template_body: template_body,
|
91
|
+
template_format: template_format,
|
92
|
+
role_arn: stack_definition.role_arn,
|
93
|
+
notification_arns: stack_definition.notification_arns,
|
94
|
+
stack_policy_body: stack_policy_body)
|
95
|
+
end
|
96
|
+
|
78
97
|
def max_template_size(use_s3)
|
79
98
|
return TemplateUtils::MAX_S3_TEMPLATE_SIZE if use_s3
|
80
99
|
TemplateUtils::MAX_TEMPLATE_SIZE
|
@@ -1,17 +1,18 @@
|
|
1
1
|
module StackMaster
|
2
2
|
class Validator
|
3
|
-
def self.valid?(stack_definition, config)
|
4
|
-
new(stack_definition, config).perform
|
3
|
+
def self.valid?(stack_definition, config, options)
|
4
|
+
new(stack_definition, config, options).perform
|
5
5
|
end
|
6
6
|
|
7
|
-
def initialize(stack_definition, config)
|
7
|
+
def initialize(stack_definition, config, options)
|
8
8
|
@stack_definition = stack_definition
|
9
9
|
@config = config
|
10
|
+
@options = options
|
10
11
|
end
|
11
12
|
|
12
13
|
def perform
|
13
14
|
StackMaster.stdout.print "#{@stack_definition.stack_name}: "
|
14
|
-
if parameter_validator.missing_parameters?
|
15
|
+
if validate_template_parameters? && parameter_validator.missing_parameters?
|
15
16
|
StackMaster.stdout.puts "invalid\n#{parameter_validator.error_message}"
|
16
17
|
return false
|
17
18
|
end
|
@@ -25,12 +26,20 @@ module StackMaster
|
|
25
26
|
|
26
27
|
private
|
27
28
|
|
29
|
+
def validate_template_parameters?
|
30
|
+
@options.validate_template_parameters
|
31
|
+
end
|
32
|
+
|
28
33
|
def cf
|
29
34
|
@cf ||= StackMaster.cloud_formation_driver
|
30
35
|
end
|
31
36
|
|
32
37
|
def stack
|
33
|
-
@stack ||=
|
38
|
+
@stack ||= if validate_template_parameters?
|
39
|
+
Stack.generate(@stack_definition, @config)
|
40
|
+
else
|
41
|
+
Stack.generate_without_parameters(@stack_definition, @config)
|
42
|
+
end
|
34
43
|
end
|
35
44
|
|
36
45
|
def parameter_validator
|
data/lib/stack_master/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stack_master
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Hodgkiss
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -446,6 +446,7 @@ executables:
|
|
446
446
|
extensions: []
|
447
447
|
extra_rdoc_files: []
|
448
448
|
files:
|
449
|
+
- LICENSE.txt
|
449
450
|
- README.md
|
450
451
|
- bin/stack_master
|
451
452
|
- lib/stack_master.rb
|
@@ -538,8 +539,8 @@ licenses:
|
|
538
539
|
metadata:
|
539
540
|
bug_tracker_uri: https://github.com/envato/stack_master/issues
|
540
541
|
changelog_uri: https://github.com/envato/stack_master/blob/master/CHANGELOG.md
|
541
|
-
documentation_uri: https://www.rubydoc.info/gems/stack_master/2.
|
542
|
-
source_code_uri: https://github.com/envato/stack_master/tree/v2.
|
542
|
+
documentation_uri: https://www.rubydoc.info/gems/stack_master/2.5.0
|
543
|
+
source_code_uri: https://github.com/envato/stack_master/tree/v2.5.0
|
543
544
|
post_install_message:
|
544
545
|
rdoc_options: []
|
545
546
|
require_paths:
|