sfn 1.1.10 → 1.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/docs/callbacks.md +4 -2
- data/docs/overview.md +1 -1
- data/lib/sfn/command/list.rb +2 -2
- data/lib/sfn/command/update.rb +9 -8
- data/lib/sfn/command_module/template.rb +6 -0
- data/lib/sfn/planner.rb +5 -1
- data/lib/sfn/planner/aws.rb +55 -19
- data/lib/sfn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7c94cea72644d2789ca1bbc6bb3a235e6f45356
|
4
|
+
data.tar.gz: 67108e9ccf029399a1892ed96e520db1515b4216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aff9a0b880bf2173a721107d5ad9fbea43af78f6b1aa6ed2e650a705b298679e7287355684cbca221cc19fd3e433403cf3eff0294483827fcaa1aee9aecd4dd6
|
7
|
+
data.tar.gz: eabc758d5854532e50aa9b1905d2518b3d6f7e37bcc79a3c1046308ce1e4d702f542ceb87768a3df14ea96c4a761cd5bfaa1fa68080d660e73616dac1fac5bf3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## v1.1.12
|
2
|
+
* [enhancement] Include updated time information on stack list
|
3
|
+
* [enhancement] Support pseudo-parameters in update planning
|
4
|
+
* AWS only as it is currently the only implementation
|
5
|
+
|
1
6
|
## v1.1.10
|
2
7
|
* [enhancement] Better configuration related errors
|
3
8
|
* [fix] Planning display on stack removal (#75)
|
data/docs/callbacks.md
CHANGED
@@ -80,8 +80,10 @@ Builtin callbacks distributed with `sfn`:
|
|
80
80
|
|
81
81
|
#### Stack Policy Callback
|
82
82
|
|
83
|
-
The Stack Policy Callback utilizes the [policy feature]
|
84
|
-
built into the [SparkleFormation]
|
83
|
+
The Stack Policy Callback utilizes the [policy feature](http://www.sparkleformation.io/docs/sparkle_formation/stack-policies.html)
|
84
|
+
built into the [SparkleFormation](http://www.sparkleformation.io/docs/sparkle_formation)
|
85
|
+
library.
|
86
|
+
|
85
87
|
To enable the callback:
|
86
88
|
|
87
89
|
~~~ruby
|
data/docs/overview.md
CHANGED
data/lib/sfn/command/list.rb
CHANGED
@@ -48,9 +48,9 @@ module Sfn
|
|
48
48
|
# @return [Array<String>] default attributes to display
|
49
49
|
def default_attributes
|
50
50
|
if(provider.connection.provider == :aws)
|
51
|
-
%w(name created status template_description)
|
51
|
+
%w(name created updated status template_description)
|
52
52
|
else
|
53
|
-
%w(name created status description)
|
53
|
+
%w(name created updated status description)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
data/lib/sfn/command/update.rb
CHANGED
@@ -164,57 +164,58 @@ module Sfn
|
|
164
164
|
|
165
165
|
|
166
166
|
def print_plan_result(info, names=[])
|
167
|
-
|
167
|
+
said_any_things = false
|
168
168
|
unless(info[:stacks].empty?)
|
169
169
|
info[:stacks].each do |s_name, s_info|
|
170
170
|
said_things = print_plan_result(s_info, [*names, s_name].compact)
|
171
171
|
end
|
172
172
|
end
|
173
173
|
unless(names.flatten.compact.empty?)
|
174
|
+
said_things = false
|
174
175
|
ui.puts
|
175
176
|
ui.puts " #{ui.color('Update plan for:', :bold)} #{ui.color(names.join(' > '), :blue)}"
|
176
177
|
unless(info[:unknown].empty?)
|
177
178
|
ui.puts " #{ui.color('!!! Unknown update effect:', :red, :bold)}"
|
178
179
|
print_plan_items(info, :unknown, :red)
|
179
180
|
ui.puts
|
180
|
-
said_things = true
|
181
|
+
said_any_things = said_things = true
|
181
182
|
end
|
182
183
|
unless(info[:unavailable].empty?)
|
183
184
|
ui.puts " #{ui.color('Update request not allowed:', :red, :bold)}"
|
184
185
|
print_plan_items(info, :unavailable, :red)
|
185
186
|
ui.puts
|
186
|
-
said_things = true
|
187
|
+
said_any_things = said_things = true
|
187
188
|
end
|
188
189
|
unless(info[:replace].empty?)
|
189
190
|
ui.puts " #{ui.color('Resources to be replaced:', :red, :bold)}"
|
190
191
|
print_plan_items(info, :replace, :red)
|
191
192
|
ui.puts
|
192
|
-
said_things = true
|
193
|
+
said_any_things = said_things = true
|
193
194
|
end
|
194
195
|
unless(info[:interrupt].empty?)
|
195
196
|
ui.puts " #{ui.color('Resources to be interrupted:', :yellow, :bold)}"
|
196
197
|
print_plan_items(info, :interrupt, :yellow)
|
197
198
|
ui.puts
|
198
|
-
said_things = true
|
199
|
+
said_any_things = said_things = true
|
199
200
|
end
|
200
201
|
unless(info[:removed].empty?)
|
201
202
|
ui.puts " #{ui.color('Resources to be removed:', :red, :bold)}"
|
202
203
|
print_plan_items(info, :removed, :red)
|
203
204
|
ui.puts
|
204
|
-
said_things = true
|
205
|
+
said_any_things = said_things = true
|
205
206
|
end
|
206
207
|
unless(info[:added].empty?)
|
207
208
|
ui.puts " #{ui.color('Resources to be added:', :green, :bold)}"
|
208
209
|
print_plan_items(info, :added, :green)
|
209
210
|
ui.puts
|
210
|
-
said_things = true
|
211
|
+
said_any_things = said_things = true
|
211
212
|
end
|
212
213
|
unless(said_things)
|
213
214
|
ui.puts " #{ui.color('No resource lifecycle changes detected!', :green)}"
|
214
215
|
ui.puts
|
215
216
|
end
|
216
217
|
end
|
217
|
-
|
218
|
+
said_any_things
|
218
219
|
end
|
219
220
|
|
220
221
|
# Print planning items
|
@@ -247,6 +247,12 @@ module Sfn
|
|
247
247
|
)
|
248
248
|
unless(config[:plan])
|
249
249
|
resource.properties.delete!(:stack)
|
250
|
+
else
|
251
|
+
(stack_definition['Resources'] || {}).each do |_, info|
|
252
|
+
if(valid_stack_types.include?(info['Type']))
|
253
|
+
info['Properties'].delete('Stack')
|
254
|
+
end
|
255
|
+
end
|
250
256
|
end
|
251
257
|
bucket = provider.connection.api_for(:storage).buckets.get(
|
252
258
|
config[:nesting_bucket]
|
data/lib/sfn/planner.rb
CHANGED
@@ -14,6 +14,8 @@ module Sfn
|
|
14
14
|
attr_reader :arguments
|
15
15
|
# @return [Miasma::Models::Orchestration::Stack] existing remote stack
|
16
16
|
attr_reader :origin_stack
|
17
|
+
# @return [Hash] custom options
|
18
|
+
attr_reader :options
|
17
19
|
|
18
20
|
# Create a new planner instance
|
19
21
|
#
|
@@ -21,13 +23,15 @@ module Sfn
|
|
21
23
|
# @param config [Smash]
|
22
24
|
# @param arguments [Array<String>]
|
23
25
|
# @param stack [Miasma::Models::Orchestration::Stack]
|
26
|
+
# @param opts [Hash]
|
24
27
|
#
|
25
28
|
# @return [self]
|
26
|
-
def initialize(ui, config, arguments, stack)
|
29
|
+
def initialize(ui, config, arguments, stack, opts={})
|
27
30
|
@ui = ui
|
28
31
|
@config = config
|
29
32
|
@arguments = arguments
|
30
33
|
@origin_stack = stack
|
34
|
+
@options = opts
|
31
35
|
end
|
32
36
|
|
33
37
|
# Generate update report
|
data/lib/sfn/planner/aws.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'pp'
|
2
|
-
|
3
|
-
|
4
1
|
require 'sfn'
|
5
2
|
require 'sparkle_formation/aws'
|
6
3
|
require 'hashdiff'
|
@@ -13,11 +10,15 @@ module Sfn
|
|
13
10
|
# Customized translator to dereference template
|
14
11
|
class Translator < SparkleFormation::Translation
|
15
12
|
|
13
|
+
MAP = {}
|
14
|
+
REF_MAPPING = {}
|
15
|
+
FN_MAPPING = {}
|
16
|
+
|
16
17
|
# @return [Array<String>] flagged items for value replacement
|
17
18
|
attr_reader :flagged
|
18
19
|
|
19
20
|
# Override to init flagged array
|
20
|
-
def initialize(
|
21
|
+
def initialize(template_hash, args={})
|
21
22
|
super
|
22
23
|
@flagged = []
|
23
24
|
end
|
@@ -147,6 +148,21 @@ module Sfn
|
|
147
148
|
|
148
149
|
protected
|
149
150
|
|
151
|
+
# Set global parameters available for all template translations.
|
152
|
+
# These are pseudo-parameters that are provided by the
|
153
|
+
# orchestration api runtime.
|
154
|
+
#
|
155
|
+
# @return [Hash]
|
156
|
+
def get_global_parameters(stack)
|
157
|
+
Smash.new(
|
158
|
+
'AWS::Region' => stack.api.aws_region,
|
159
|
+
'AWS::AccountId' => stack.id.split(':')[4],
|
160
|
+
'AWS::NotificationARNs' => stack.notification_topics,
|
161
|
+
'AWS::StackId' => stack.id,
|
162
|
+
'AWS::StackName' => stack.name
|
163
|
+
).merge(config.fetch(:planner, :global_parameters, {}))
|
164
|
+
end
|
165
|
+
|
150
166
|
# Generate plan for stack
|
151
167
|
#
|
152
168
|
# @param stack [Miasma::Models::Orchestration::Stack]
|
@@ -166,7 +182,11 @@ module Sfn
|
|
166
182
|
:n_outputs => []
|
167
183
|
)
|
168
184
|
|
169
|
-
origin_template = dereference_template(
|
185
|
+
origin_template = dereference_template(
|
186
|
+
"#{stack.data.checksum}_origin",
|
187
|
+
stack.template,
|
188
|
+
stack.parameters.merge(get_global_parameters(stack))
|
189
|
+
)
|
170
190
|
|
171
191
|
t_key = "#{stack.data.checksum}_#{stack.data.fetch(:logical_id, stack.name)}"
|
172
192
|
run_stack_diff(stack, t_key, plan_results, origin_template, new_template, new_parameters)
|
@@ -227,23 +247,22 @@ module Sfn
|
|
227
247
|
end
|
228
248
|
end
|
229
249
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
)
|
250
|
+
new_parameters.merge!(get_global_parameters(stack))
|
251
|
+
|
252
|
+
new_template_hash = new_template.to_smash
|
234
253
|
|
235
254
|
o_nested_stacks = origin_template['Resources'].find_all do |s_name, s_val|
|
236
255
|
is_stack?(s_val['Type'])
|
237
256
|
end.map(&:first)
|
238
|
-
n_nested_stacks =
|
257
|
+
n_nested_stacks = new_template_hash['Resources'].find_all do |s_name, s_val|
|
239
258
|
is_stack?(s_val['Type'])
|
240
259
|
end.map(&:first)
|
241
260
|
[o_nested_stacks + n_nested_stacks].flatten.compact.uniq.each do |n_name|
|
242
261
|
o_stack = stack.nested_stacks(false).detect{|s| s.data[:logical_id] == n_name}
|
243
|
-
n_exists = is_stack?(
|
244
|
-
n_template =
|
245
|
-
n_parameters =
|
246
|
-
n_type =
|
262
|
+
n_exists = is_stack?(new_template_hash['Resources'].fetch(n_name, {})['Type'])
|
263
|
+
n_template = new_template_hash['Resources'].fetch(n_name, {}).fetch('Properties', {})['Stack']
|
264
|
+
n_parameters = new_template_hash['Resources'].fetch(n_name, {}).fetch('Properties', {}).fetch('Parameters', {})
|
265
|
+
n_type = new_template_hash['Resources'].fetch(n_name, {})['Type'] ||
|
247
266
|
origin_template['Resources'][n_name]['Type']
|
248
267
|
resource = Smash.new(
|
249
268
|
:name => n_name,
|
@@ -267,9 +286,16 @@ module Sfn
|
|
267
286
|
plan_results[:added][n_name] = resource
|
268
287
|
end
|
269
288
|
end
|
289
|
+
|
270
290
|
n_nested_stacks.each do |ns_name|
|
271
|
-
|
291
|
+
new_template_hash['Resources'][ns_name]['Properties'].delete('Stack')
|
272
292
|
end
|
293
|
+
|
294
|
+
update_template = dereference_template(
|
295
|
+
t_key, new_template_hash, new_parameters,
|
296
|
+
plan_results[:replace].keys + plan_results[:unavailable].keys
|
297
|
+
)
|
298
|
+
|
273
299
|
HashDiff.diff(origin_template, MultiJson.load(MultiJson.dump(update_template))).group_by do |item|
|
274
300
|
item[1]
|
275
301
|
end.each do |a_path, diff_items|
|
@@ -374,8 +400,14 @@ module Sfn
|
|
374
400
|
flagged.each do |item|
|
375
401
|
translator.flag_ref(item)
|
376
402
|
end
|
377
|
-
template
|
378
|
-
|
403
|
+
template.keys.each do |t_key|
|
404
|
+
next if ['Outputs', 'Resources'].include?(t_key)
|
405
|
+
template[t_key] = translator.dereference_processor(template[t_key], ['Ref', 'Fn', 'DEREF', 'Fn::FindInMap'])
|
406
|
+
end
|
407
|
+
translator.original.replace(template)
|
408
|
+
template['Resources'] = translator.dereference_processor(template['Resources'], ['Ref', 'Fn', 'DEREF', 'Fn::FindInMap'])
|
409
|
+
template['Outputs'] = translator.dereference_processor(template['Outputs'], ['Ref', 'Fn', 'DEREF', 'Fn::FindInMap'])
|
410
|
+
translator.original.replace({})
|
379
411
|
template
|
380
412
|
end
|
381
413
|
|
@@ -388,7 +420,9 @@ module Sfn
|
|
388
420
|
def translator_for(t_key, template=nil, parameters=nil)
|
389
421
|
o_translator = translators[t_key]
|
390
422
|
if(template)
|
391
|
-
translator = Translator.new(template,
|
423
|
+
translator = Translator.new(template,
|
424
|
+
:parameters => parameters
|
425
|
+
)
|
392
426
|
if(o_translator)
|
393
427
|
o_translator.flagged.each do |i|
|
394
428
|
translator.flag_ref(i)
|
@@ -398,7 +432,9 @@ module Sfn
|
|
398
432
|
o_translator = translator
|
399
433
|
else
|
400
434
|
unless(o_translator)
|
401
|
-
o_translator = Translator.new({},
|
435
|
+
o_translator = Translator.new({},
|
436
|
+
:parameters => {}
|
437
|
+
)
|
402
438
|
end
|
403
439
|
end
|
404
440
|
o_translator
|
data/lib/sfn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo-cli
|