stackit 0.3.17 → 0.3.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e9d5f784a1c923609a654385cad4047b44d9b68
4
- data.tar.gz: 0c0d4e33a5e37f8672a68bb8b866951cb2ea350b
3
+ metadata.gz: 826466c19841c00ed09ad5fec9af5862d47496b0
4
+ data.tar.gz: 3bb52fa36f06cda7d1cf28517820c062068790cf
5
5
  SHA512:
6
- metadata.gz: 4cc751bdd14d225f92ba0ef76ad679b72c7f998c0f14438a516c1a77ba5c17b64262d028dbb1a90a3e5b2de906384f696cd6f2411ffb7af8764f1718071fd605
7
- data.tar.gz: 7eec6eec79e33abb751e0e834842c50199f24ea90df487be95cfc9835384592784aa44cd1a35566866bcbe2bc14bfcc2e4aa92c6d2d02ea2e5315e481c20f618
6
+ metadata.gz: a827ff209fec39d98bf386a5d21eb160c6dba259266fa49a2dd9d7be317da7532f988032be8f0a665afba8f82133b1179016c87cdd10be7d298afdea581edfc2
7
+ data.tar.gz: 24ba977cffa979fafb9d79b5a7b7b5569c0bff95bbc639b2975bf22e356a6581f725922123887cc036fb897acacfde120bd9303517a3fb4ade88864f37db427f
@@ -22,6 +22,7 @@ module Stackit
22
22
  attr_accessor :on_failure
23
23
  attr_accessor :use_previous_template
24
24
  attr_accessor :retain_resources
25
+ attr_accessor :change_set_name
25
26
 
26
27
  def initialize(options = {})
27
28
  options = options.to_h.symbolize_keys!
@@ -37,6 +38,7 @@ module Stackit
37
38
  self.on_failure = options[:on_failure]
38
39
  self.use_previous_template = options[:use_previous_template]
39
40
  self.retain_resources = options[:retain_resources]
41
+ self.change_set_name = options[:change_set_name]
40
42
  end
41
43
 
42
44
  def [](key)
@@ -143,6 +145,17 @@ module Stackit
143
145
  }
144
146
  end
145
147
 
148
+ def change_set_request_params
149
+ {
150
+ change_set_name: change_set_name || "#{stack_name}#{Time.now.strftime("%m%d%Y%H%M%S")}",
151
+ stack_name: stack_name,
152
+ use_previous_template: use_previous_template,
153
+ parameters: to_request_parameters,
154
+ notification_arns: notification_arns,
155
+ tags: to_request_tags
156
+ }
157
+ end
158
+
146
159
  private
147
160
 
148
161
  def stack
@@ -127,6 +127,20 @@ module Stackit
127
127
  describe != nil
128
128
  end
129
129
 
130
+ def change_set!
131
+ begin
132
+ response = cloudformation_request(:create_change_set)
133
+ notifier.response(response)
134
+ rescue ::Aws::CloudFormation::Errors::AlreadyExistsException => e
135
+ notifier.backtrace(e) if Stackit.debug
136
+ notifier.error(e.message)
137
+ rescue ::Aws::CloudFormation::Errors::ValidationError => e
138
+ notifier.backtrace(e) if Stackit.debug
139
+ notifier.error(e.message)
140
+ end
141
+ response
142
+ end
143
+
130
144
  def describe
131
145
  response = cloudformation_request(:describe_stacks)
132
146
  if response && response[:stacks]
@@ -252,8 +266,14 @@ module Stackit
252
266
  capabilities: capabilities,
253
267
  use_previous_template: template.options[:template_body].nil? && template.options[:template_url].nil?
254
268
  )
255
- else
269
+ when :delete_stack
256
270
  delete_stack_request_params
271
+ when :create_change_set
272
+ change_set_request_params.merge(template.options).merge(
273
+ parameters: to_request_parameters(merged_parameters),
274
+ capabilities: capabilities,
275
+ use_previous_template: template.options[:template_body].nil? && template.options[:template_url].nil?
276
+ )
257
277
  end
258
278
  end
259
279
 
@@ -7,7 +7,7 @@ module Stackit
7
7
  attr_accessor :stack_action
8
8
 
9
9
  def initialize(options)
10
- self.options = options
10
+ self.options = options || {}
11
11
  end
12
12
 
13
13
  def create!
@@ -25,6 +25,11 @@ module Stackit
25
25
  final_stack.delete!
26
26
  end
27
27
 
28
+ def change_set!
29
+ self.stack_action = :change_set!
30
+ final_stack.change_set!
31
+ end
32
+
28
33
  def stack_name
29
34
  options[:stack_name] || "#{Stackit.environment}-#{options[:stack_name]}"
30
35
  end
@@ -51,9 +56,7 @@ module Stackit
51
56
  end
52
57
 
53
58
  def depends_on(deps)
54
- if options[:depends] && options[:depends].empty?
55
- options[:depends] = deps
56
- end
59
+ options[:depends] = deps
57
60
  end
58
61
 
59
62
  def parameter_mappings
@@ -116,6 +119,10 @@ module Stackit
116
119
  options[:use_previous_template]
117
120
  end
118
121
 
122
+ def change_set_name
123
+ options[:change_set_name]
124
+ end
125
+
119
126
  def stack
120
127
  @stack ||= ManagedStack.new(
121
128
  template: template,
@@ -136,7 +143,8 @@ module Stackit
136
143
  tags: tags,
137
144
  on_failure: on_failure,
138
145
  use_previous_template: use_previous_template,
139
- retain_resources: retain_resources
146
+ retain_resources: retain_resources,
147
+ change_set_name: change_set_name
140
148
  )
141
149
  end
142
150
 
@@ -155,10 +163,12 @@ module Stackit
155
163
  end
156
164
 
157
165
  def resolve_parameter(key)
166
+ Stackit.logger.debug "Resolving parameter: #{key}"
158
167
  Stackit::ParameterResolver.new(depends_stacks).resolve(key)
159
168
  end
160
169
 
161
170
  def resolve_parameters(keys)
171
+ Stackit.logger.debug "Resolving parameters: #{keys.join(', ')}"
162
172
  Stackit::ParameterResolver.new(depends_stacks).resolve(keys)
163
173
  end
164
174
 
@@ -1,3 +1,3 @@
1
1
  module Stackit
2
- VERSION = "0.3.17"
2
+ VERSION = "0.3.19"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.17
4
+ version: 0.3.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Hahn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-30 00:00:00.000000000 Z
11
+ date: 2017-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler