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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbde49a4efbd662200baecfed8b4b7c40f9c340c
4
- data.tar.gz: e565d4fb07afca1d2410afa98734ae455bf350f5
3
+ metadata.gz: 376c009d8b1dc4acd9857ddd96121935a46260de
4
+ data.tar.gz: e850d0f6dc207dd5e56b1b1b4f46911b1bf3b022
5
5
  SHA512:
6
- metadata.gz: 02c76bfdafbd85d0c7e186013fee0fac15540d71b93de8694b5f92577120e87decd6ea0b18f34171dcb67671fc79d684e9d5c71bc7577f116bd3661f9e48dabc
7
- data.tar.gz: 83bb2a02c71e87d3ab04861797170a219c442cee989c19b46a0380d90190ab03e4b1839b8f7a07d407b4debbd2bfcec0825921b74fb5f31daa199de6b63b0d76
6
+ metadata.gz: cf63e60888843e5ce0702cbdbaa909dea98c92bccc234cd0c9de0178c3a2754fded5d6d9025e2002fda12f8623c473f865a1c9d14cd343654c7c8012b2caf60d
7
+ data.tar.gz: b39fafa969cfa402d0715b27b846d2390bc254d8a516407ed170e91de0672b92c6426f112febac870394bfa9abb43820fe0a23ce05529b3d32d617e6d40a3087
data/bin/stackit CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  $:.push File.expand_path('../../lib', __FILE__)
3
- require 'stackit/cli/base_cli'
4
3
  require 'stackit/cli/stack_cli'
5
4
  require 'stackit/cli/stackit_cli'
6
5
  Stackit::StackitCli.start
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
@@ -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]
@@ -0,0 +1,10 @@
1
+ {
2
+ "Statement" : [
3
+ {
4
+ "Effect" : "Allow",
5
+ "NotAction" : ["Update:Replace", "Update:Delete"],
6
+ "Principal": "*",
7
+ "Resource" : "*"
8
+ }
9
+ ]
10
+ }
@@ -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
- end
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
- pp opts
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({
@@ -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 =~ /^https:\/\/s3\.amazonaws\.com/
17
+ if @template_path =~ /^http/
18
18
  @options[:template_url] = @template_path
19
19
  else
20
20
  @options[:template_body] = body
@@ -1,3 +1,3 @@
1
1
  module Stackit
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
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.1.5
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-14 00:00:00.000000000 Z
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