stackit 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/stackit +0 -1
- data/lib/stackit.rb +6 -0
- data/lib/stackit/cli/base_cli.rb +0 -16
- data/lib/stackit/stack/default-stack-policy.json +10 -0
- data/lib/stackit/stack/managed_stack.rb +67 -43
- data/lib/stackit/template.rb +1 -1
- data/lib/stackit/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 376c009d8b1dc4acd9857ddd96121935a46260de
|
4
|
+
data.tar.gz: e850d0f6dc207dd5e56b1b1b4f46911b1bf3b022
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf63e60888843e5ce0702cbdbaa909dea98c92bccc234cd0c9de0178c3a2754fded5d6d9025e2002fda12f8623c473f865a1c9d14cd343654c7c8012b2caf60d
|
7
|
+
data.tar.gz: b39fafa969cfa402d0715b27b846d2390bc254d8a516407ed170e91de0672b92c6426f112febac870394bfa9abb43820fe0a23ce05529b3d32d617e6d40a3087
|
data/bin/stackit
CHANGED
data/lib/stackit.rb
CHANGED
@@ -16,8 +16,10 @@ module Stackit
|
|
16
16
|
|
17
17
|
attr_accessor :aws
|
18
18
|
attr_accessor :cloudformation
|
19
|
+
attr_accessor :logger
|
19
20
|
attr_accessor :environment
|
20
21
|
attr_accessor :debug
|
22
|
+
attr_accessor :home
|
21
23
|
|
22
24
|
def aws
|
23
25
|
@aws ||= Stackit::Aws.new
|
@@ -39,5 +41,9 @@ module Stackit
|
|
39
41
|
@debug ||= false
|
40
42
|
end
|
41
43
|
|
44
|
+
def home
|
45
|
+
Pathname.new(File.expand_path('stackit.gemspec', __dir__)).dirname
|
46
|
+
end
|
47
|
+
|
42
48
|
end
|
43
49
|
end
|
data/lib/stackit/cli/base_cli.rb
CHANGED
@@ -28,25 +28,9 @@ module Stackit
|
|
28
28
|
true
|
29
29
|
end
|
30
30
|
|
31
|
-
desc 'version', 'Displays StackIT version'
|
32
|
-
def version
|
33
|
-
puts <<-LOGO
|
34
|
-
_____ _ _ _______ _______
|
35
|
-
(_____) (_)_ (_) _ (_______)(__ _ __)
|
36
|
-
(_)___ (___) ____ ___ (_)(_) (_) (_)
|
37
|
-
(___)_ (_) (____) _(___)(___) (_) (_)
|
38
|
-
____(_)(_)_( )_( )(_)___ (_)(_) __(_)__ (_)
|
39
|
-
(_____) (__)(__)_) (____)(_) (_)(_______) (_) v#{Stackit::VERSION}
|
40
|
-
|
41
|
-
Simple, elegant CloudFormation dependency management.
|
42
|
-
|
43
|
-
LOGO
|
44
|
-
end
|
45
|
-
|
46
31
|
no_commands do
|
47
32
|
|
48
33
|
def init_cli
|
49
|
-
|
50
34
|
Stackit.aws.region = options[:region] if options[:region]
|
51
35
|
Stackit.environment = options[:environment].to_sym if options[:environment]
|
52
36
|
Stackit.debug = !!options[:debug]
|
@@ -14,7 +14,6 @@ module Stackit
|
|
14
14
|
|
15
15
|
def initialize(options={})
|
16
16
|
super(options)
|
17
|
-
options = options.to_h.symbolize_keys!
|
18
17
|
@template = create_template(options[:template])
|
19
18
|
@user_defined_parameters = symbolized_user_defined_parameters(options[:user_defined_parameters])
|
20
19
|
@parameter_map = symbolized_parameter_map(options[:parameter_map])
|
@@ -26,46 +25,8 @@ module Stackit
|
|
26
25
|
@dry_run = options[:dry_run]
|
27
26
|
@notifier = options[:notifier] || Stackit::ThorNotifier.new
|
28
27
|
parse_file_parameters(options[:parameters_file]) if options[:parameters_file]
|
29
|
-
|
30
|
-
|
31
|
-
def symbolized_user_defined_parameters(params)
|
32
|
-
if params
|
33
|
-
params.symbolize_keys!
|
34
|
-
else
|
35
|
-
{}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def symbolized_parameter_map(param_map)
|
40
|
-
if param_map
|
41
|
-
param_map.symbolize_keys!
|
42
|
-
else
|
43
|
-
{}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def default_stack_name
|
48
|
-
self.class.name.demodulize
|
49
|
-
end
|
50
|
-
|
51
|
-
def create_template(t)
|
52
|
-
template_path = t ? t : File.join(Dir.pwd, 'cloudformation', "#{stack_name.underscore.dasherize}.json")
|
53
|
-
return unless File.exist?(template_path)
|
54
|
-
template = Template.new(
|
55
|
-
:cloudformation => cloudformation,
|
56
|
-
:template_path => template_path
|
57
|
-
)
|
58
|
-
template.parse!
|
59
|
-
end
|
60
|
-
|
61
|
-
def parse_file_parameters(parameters_file)
|
62
|
-
if File.exist?(parameters_file)
|
63
|
-
@file_parameters = {}
|
64
|
-
file_params = JSON.parse(File.read(parameters_file))
|
65
|
-
file_params.inject(@file_parameters) do |hash, param|
|
66
|
-
hash.merge!(param['ParameterKey'].to_sym => param['ParameterValue'])
|
67
|
-
end
|
68
|
-
end
|
28
|
+
create_stack_policy(options[:stack_policy])
|
29
|
+
create_stack_policy_during_update(options[:stack_policy_during_update])
|
69
30
|
end
|
70
31
|
|
71
32
|
def create!
|
@@ -178,6 +139,70 @@ module Stackit
|
|
178
139
|
DRY_RUN_RESPONSE = Struct.new(:stack_id)
|
179
140
|
REDACTED_TEXT = '****redacted****'
|
180
141
|
|
142
|
+
def symbolized_user_defined_parameters(params)
|
143
|
+
if params
|
144
|
+
params.symbolize_keys!
|
145
|
+
else
|
146
|
+
{}
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def symbolized_parameter_map(param_map)
|
151
|
+
if param_map
|
152
|
+
param_map.symbolize_keys!
|
153
|
+
else
|
154
|
+
{}
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def default_stack_name
|
159
|
+
self.class.name.demodulize
|
160
|
+
end
|
161
|
+
|
162
|
+
def create_template(t)
|
163
|
+
template_path = t ? t : File.join(Dir.pwd, 'cloudformation', "#{stack_name.underscore.dasherize}.json")
|
164
|
+
return unless File.exist?(template_path)
|
165
|
+
template = Template.new(
|
166
|
+
:cloudformation => cloudformation,
|
167
|
+
:template_path => template_path
|
168
|
+
)
|
169
|
+
template.parse!
|
170
|
+
end
|
171
|
+
|
172
|
+
def create_stack_policy(f)
|
173
|
+
policy_path = f ? f : File.join(Stackit.home, 'stackit', 'stack', 'default-stack-policy.json')
|
174
|
+
if policy_path =~ /^http/
|
175
|
+
self.stack_policy_url = policy_path
|
176
|
+
else
|
177
|
+
raise "Unable to locate policy: #{policy_path}" unless File.exist?(policy_path)
|
178
|
+
self.stack_policy_body = File.read(policy_path)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def create_stack_policy_during_update(f)
|
183
|
+
policy_path = f ? f : File.join(Dir.pwd, "#{stack_name}-update-policy.json")
|
184
|
+
if !File.exist?(policy_path)
|
185
|
+
Stackit.logger.warn "Unable to locate stack policy during update file: #{policy_path}"
|
186
|
+
return
|
187
|
+
end
|
188
|
+
if policy_path =~ /^http/
|
189
|
+
self.stack_policy_during_update_url = policy_path
|
190
|
+
else
|
191
|
+
raise "Unable to locate update policy: #{policy_path}" unless File.exist?(policy_path)
|
192
|
+
self.stack_policy_during_update_body = File.read(policy_path)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def parse_file_parameters(parameters_file)
|
197
|
+
if File.exist?(parameters_file)
|
198
|
+
@file_parameters = {}
|
199
|
+
file_params = JSON.parse(File.read(parameters_file))
|
200
|
+
file_params.inject(@file_parameters) do |hash, param|
|
201
|
+
hash.merge!(param['ParameterKey'].to_sym => param['ParameterValue'])
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
181
206
|
def capabilities
|
182
207
|
template.needs_iam_capability? ? ['CAPABILITY_IAM'] : []
|
183
208
|
end
|
@@ -198,7 +223,7 @@ module Stackit
|
|
198
223
|
opts[:stack_policy_body] = JSON.parse(opts[:stack_policy_body]) if opts[:stack_policy_body]
|
199
224
|
opts[:stack_policy_during_update_body] =
|
200
225
|
JSON.parse(opts[:stack_policy_during_update_body]) if opts[:stack_policy_during_update_body]
|
201
|
-
|
226
|
+
pp opts
|
202
227
|
end
|
203
228
|
response = dry_run ? dry_run_response : cloudformation.send(action, cloudformation_options)
|
204
229
|
wait_for_stack if wait
|
@@ -225,7 +250,6 @@ module Stackit
|
|
225
250
|
def merged_parameters
|
226
251
|
merged_params = template.parsed_parameters
|
227
252
|
return parsed_parameters unless depends.length
|
228
|
-
# merge file parameters
|
229
253
|
merged_params.merge!(file_parameters) if file_parameters
|
230
254
|
depends.each do |dependent_stack_name|
|
231
255
|
this_stack = Stack.new({
|
data/lib/stackit/template.rb
CHANGED
@@ -14,7 +14,7 @@ module Stackit
|
|
14
14
|
|
15
15
|
def parse!
|
16
16
|
Stackit.logger.info "Parsing cloudformation template: #{template_path}"
|
17
|
-
if @template_path =~ /^
|
17
|
+
if @template_path =~ /^http/
|
18
18
|
@options[:template_url] = @template_path
|
19
19
|
else
|
20
20
|
@options[:template_body] = body
|
data/lib/stackit/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.7
|
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-04-
|
11
|
+
date: 2016-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/stackit/cli/stack_cli.rb
|
147
147
|
- lib/stackit/cli/stackit_cli.rb
|
148
148
|
- lib/stackit/stack.rb
|
149
|
+
- lib/stackit/stack/default-stack-policy.json
|
149
150
|
- lib/stackit/stack/default_notifier.rb
|
150
151
|
- lib/stackit/stack/managed_stack.rb
|
151
152
|
- lib/stackit/template.rb
|