hygroscope 1.1.7 → 1.2.0

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: c30412dca6b04d119cc3faeaa816022ce900feb0
4
- data.tar.gz: 06409b36b30e590c074b02cbb29e0aea6bf9d13f
3
+ metadata.gz: 6843b8aec13ea4cea7186e3e0d303bf9fb9a3fcc
4
+ data.tar.gz: e8892054ee9e904e1c3d668c56866d01d5f9e624
5
5
  SHA512:
6
- metadata.gz: c646b4a25667cc80db36202ceda848984557723d27f14fc83fe484df0b4d3266dc3a1782f7603aadda64fe3ca072342e28cc1151f67a41b49bafb3a9160aed4c
7
- data.tar.gz: c578d854060fd6c4aba017d04320d6c92b479118f3d168228de1c9abf0d4552939dc56d85200bc5811cb148380c8b15c2e96f66cb9a5fc60c0bf5e22a1f4a6b1
6
+ metadata.gz: cd09dd561634d91ce8ed58851c58b58e445cfb5e275119923ee6fb7a977d66e486d96143e035ac8566d70a257cc3f51c07e2adfacb9a165724e424fbde5d6552
7
+ data.tar.gz: 8b508549617eee3670492368d9616bba7293e6072d6199ebe944fe9553b74e8a487b03fa4e4ac7f8d06caecf989639ad8cf1024481d30c686002c157be657248
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  *.gem
2
2
  .bundle
3
3
  Gemfile.lock
4
+ .ruby-version
@@ -1,6 +1,10 @@
1
+ ## 1.2.0 (2015-10-08)
2
+ - Support AWS credential profiles and multiple regions using new --region and
3
+ --profile options.
4
+
1
5
  ## 1.1.6 (2015-03-23)
2
6
 
3
- - Bugfix for tag functionality (failed if no tags are specified)
7
+ - Bugfix for tag functionality (failed if no tags are specified).
4
8
 
5
9
  ## 1.1.5 (2015-03-23)
6
10
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'hygroscope'
3
- s.version = '1.1.7'
3
+ s.version = '1.2.0'
4
4
  s.summary = 'CloudFormation launcher'
5
5
  s.description = 'A tool for managing the launch of complex CloudFormation stacks'
6
6
  s.authors = ['Daniel Silverman']
@@ -78,10 +78,23 @@ module Hygroscope
78
78
  end
79
79
  end
80
80
 
81
+ # NOTE: Profiles cannot assume roles, see:
82
+ # https://github.com/aws/aws-sdk-ruby/issues/910
83
+ class_option :profile,
84
+ aliases: '-p',
85
+ type: :string,
86
+ default: 'default',
87
+ desc: 'AWS account credentials profile name'
88
+ class_option :region,
89
+ aliases: '-r',
90
+ type: :string,
91
+ default: 'us-east-1',
92
+ desc: 'AWS region'
93
+
81
94
  desc 'prepare', 'Prepare to create or update a stack by generating the template, assembling parameters, and managing payload upload', hide: true
82
95
  def prepare
83
96
  # Generate the template
84
- t = Hygroscope::Template.new(template_path)
97
+ t = Hygroscope::Template.new(template_path, options[:region], options[:profile])
85
98
 
86
99
  # If the paramset exists load it, otherwise instantiate an empty one
87
100
  p = Hygroscope::ParamSet.new(options[:paramset])
@@ -107,7 +120,7 @@ module Hygroscope
107
120
  options[:existing].each do |existing|
108
121
  # User specified an existing stack from which to pull outputs and
109
122
  # translate into parameters. Load the existing stack.
110
- e = Hygroscope::Stack.new(existing)
123
+ e = Hygroscope::Stack.new(existing, options[:region], options[:profile])
111
124
  say_status('info', "Populating parameters from #{existing} stack", :blue)
112
125
 
113
126
  # Fill any template parameter that matches an output from the existing
@@ -168,7 +181,7 @@ module Hygroscope
168
181
  # Upload payload
169
182
  payload_path = File.join(Dir.pwd, 'payload')
170
183
  if File.directory?(payload_path)
171
- payload = Hygroscope::Payload.new(payload_path)
184
+ payload = Hygroscope::Payload.new(payload_path, options[:region], options[:profile])
172
185
  payload.prefix = options[:name]
173
186
  payload.upload!
174
187
  p.set('HygroscopePayloadBucket', payload.bucket) if missing.include?('HygroscopePayloadBucket')
@@ -187,7 +200,7 @@ module Hygroscope
187
200
  default: File.basename(Dir.pwd),
188
201
  desc: 'Name of stack'
189
202
  method_option :paramset,
190
- aliases: '-p',
203
+ aliases: '-s',
191
204
  required: false,
192
205
  desc: 'Name of saved paramset to use (optional)'
193
206
  method_option :existing,
@@ -213,23 +226,23 @@ module Hygroscope
213
226
  # Prepare task takes care of shared logic between "create" and "update"
214
227
  template, paramset = prepare
215
228
 
216
- s = Hygroscope::Stack.new(options[:name])
217
- s.parameters = paramset.parameters
218
- s.template = template.compress
229
+ stack = Hygroscope::Stack.new(options[:name], options[:region], options[:profile])
230
+ stack.parameters = paramset.parameters
231
+ stack.template = template.compress
219
232
 
220
- s.tags['X-Hygroscope-Template'] = hygro_name
233
+ stack.tags['X-Hygroscope-Template'] = hygro_name
221
234
  options[:tags].each do |tag|
222
235
  if paramset.get(tag)
223
- s.tags[tag] = paramset.get(tag)
236
+ stack.tags[tag] = paramset.get(tag)
224
237
  else
225
238
  say_status('info', "Skipping tag #{tag} because it does not exist", :blue)
226
239
  end
227
240
  end
228
241
 
229
- s.capabilities = ['CAPABILITY_IAM']
230
- s.timeout = 60
242
+ stack.capabilities = ['CAPABILITY_IAM']
243
+ stack.timeout = 60
231
244
 
232
- s.create!
245
+ stack.create!
233
246
 
234
247
  status
235
248
  end
@@ -240,7 +253,7 @@ module Hygroscope
240
253
  default: File.basename(Dir.pwd),
241
254
  desc: 'Name of stack'
242
255
  method_option :paramset,
243
- aliases: '-p',
256
+ aliases: '-s',
244
257
  required: false,
245
258
  desc: 'Name of saved paramset to use (optional)'
246
259
  method_option :ask,
@@ -258,7 +271,7 @@ module Hygroscope
258
271
  # Prepare task takes care of shared logic between "create" and "update"
259
272
  template, paramset = prepare
260
273
 
261
- s = Hygroscope::Stack.new(options[:name])
274
+ s = Hygroscope::Stack.new(options[:name], options[:region], options[:profile])
262
275
  s.parameters = paramset.parameters
263
276
  s.template = template.compress
264
277
  s.capabilities = ['CAPABILITY_IAM']
@@ -284,7 +297,7 @@ module Hygroscope
284
297
  yes?("Really delete stack #{options[:name]} [y/N]?")
285
298
 
286
299
  say('Deleting stack!')
287
- stack = Hygroscope::Stack.new(options[:name])
300
+ stack = Hygroscope::Stack.new(options[:name], options[:region], options[:profile])
288
301
  stack.delete!
289
302
  status
290
303
  end
@@ -296,7 +309,7 @@ module Hygroscope
296
309
  desc: 'Name of stack'
297
310
  def status
298
311
  check_path
299
- stack = Hygroscope::Stack.new(options[:name])
312
+ stack = Hygroscope::Stack.new(options[:name], options[:region], options[:profile])
300
313
 
301
314
  # Query and display the status of the stack and its resources. Refresh
302
315
  # every 10 seconds until the user aborts or an error is encountered.
@@ -363,7 +376,7 @@ module Hygroscope
363
376
  desc: 'Colorize JSON output'
364
377
  def generate
365
378
  check_path
366
- t = Hygroscope::Template.new(template_path)
379
+ t = Hygroscope::Template.new(template_path, options[:region], options[:profile])
367
380
  if options[:color]
368
381
  require 'json_color'
369
382
  puts JsonColor.colorize(t.process)
@@ -377,7 +390,7 @@ module Hygroscope
377
390
  check_path
378
391
 
379
392
  begin
380
- t = Hygroscope::Template.new(template_path)
393
+ t = Hygroscope::Template.new(template_path, options[:region], options[:profile])
381
394
  t.validate
382
395
  rescue Aws::CloudFormation::Errors::ValidationError => e
383
396
  say_fail("Validation error: #{e.message}")
@@ -6,18 +6,21 @@ module Hygroscope
6
6
  attr_writer :prefix
7
7
  attr_reader :path, :bucket, :archive, :key
8
8
 
9
- def initialize(path)
9
+ def initialize(path, region, profile)
10
10
  @path = path
11
+ @region = region
12
+ @profile = profile
13
+ @credentials = Aws::SharedCredentials.new(profile_name: @profile)
11
14
 
12
15
  # TODO: This will fail if using root creds or lacking GetUser priv,
13
16
  # neither of which should be the case when using hygroscope -- but
14
17
  # we should check and error before getting to this point.
15
- @account_id = Aws::IAM::Client.new.get_user.user.arn.split(':')[4]
18
+ @account_id = Aws::IAM::Client.new(region: @region, credentials: @credentials).get_user.user.arn.split(':')[4]
16
19
  @region = ENV['AWS_REGION'] || 'us-east-1'
17
20
  @bucket = "hygroscope-payloads-#{@account_id}-#{@region}"
18
21
  @name = "payload-#{Time.new.to_i}.zip"
19
22
 
20
- @client = Aws::S3::Client.new
23
+ @client = Aws::S3::Client.new(region: @region, credentials: @credentials)
21
24
  end
22
25
 
23
26
  def prefix
@@ -6,7 +6,7 @@ module Hygroscope
6
6
  attr_writer :template, :capabilities, :on_failure, :timeout
7
7
  attr_reader :client
8
8
 
9
- def initialize(name)
9
+ def initialize(name, region, profile)
10
10
  @name = name
11
11
  @parameters = {}
12
12
  @tags = {}
@@ -14,7 +14,11 @@ module Hygroscope
14
14
  @capabilities = []
15
15
  @timeout = 15
16
16
  @on_failure = 'DO_NOTHING'
17
- @client = Aws::CloudFormation::Client.new
17
+
18
+ @region = region
19
+ @profile = profile
20
+ @credentials = Aws::SharedCredentials.new(profile_name: @profile)
21
+ @client = Aws::CloudFormation::Client.new(region: @region, credentials: @credentials)
18
22
  end
19
23
 
20
24
  def create!
@@ -8,8 +8,10 @@ module Hygroscope
8
8
  class Template
9
9
  attr_reader :path
10
10
 
11
- def initialize(path)
11
+ def initialize(path, region, profile)
12
12
  @path = path
13
+ @region = region
14
+ @profile = profile
13
15
  end
14
16
 
15
17
  # Process a set of files with cfoo and return JSON
@@ -59,7 +61,7 @@ module Hygroscope
59
61
  template = compress
60
62
 
61
63
  begin
62
- stack = Hygroscope::Stack.new('template-validator')
64
+ stack = Hygroscope::Stack.new('template-validator', @region, @profile)
63
65
  stack.client.validate_template(template_body: template)
64
66
  rescue => e
65
67
  raise e
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hygroscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Silverman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor