hygroscope 1.1.7 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +5 -1
- data/hygroscope.gemspec +1 -1
- data/lib/hygroscope/cli.rb +31 -18
- data/lib/hygroscope/payload.rb +6 -3
- data/lib/hygroscope/stack.rb +6 -2
- data/lib/hygroscope/template.rb +4 -2
- 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: 6843b8aec13ea4cea7186e3e0d303bf9fb9a3fcc
|
4
|
+
data.tar.gz: e8892054ee9e904e1c3d668c56866d01d5f9e624
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd09dd561634d91ce8ed58851c58b58e445cfb5e275119923ee6fb7a977d66e486d96143e035ac8566d70a257cc3f51c07e2adfacb9a165724e424fbde5d6552
|
7
|
+
data.tar.gz: 8b508549617eee3670492368d9616bba7293e6072d6199ebe944fe9553b74e8a487b03fa4e4ac7f8d06caecf989639ad8cf1024481d30c686002c157be657248
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
|
|
data/hygroscope.gemspec
CHANGED
data/lib/hygroscope/cli.rb
CHANGED
@@ -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: '-
|
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
|
-
|
217
|
-
|
218
|
-
|
229
|
+
stack = Hygroscope::Stack.new(options[:name], options[:region], options[:profile])
|
230
|
+
stack.parameters = paramset.parameters
|
231
|
+
stack.template = template.compress
|
219
232
|
|
220
|
-
|
233
|
+
stack.tags['X-Hygroscope-Template'] = hygro_name
|
221
234
|
options[:tags].each do |tag|
|
222
235
|
if paramset.get(tag)
|
223
|
-
|
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
|
-
|
230
|
-
|
242
|
+
stack.capabilities = ['CAPABILITY_IAM']
|
243
|
+
stack.timeout = 60
|
231
244
|
|
232
|
-
|
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: '-
|
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}")
|
data/lib/hygroscope/payload.rb
CHANGED
@@ -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
|
data/lib/hygroscope/stack.rb
CHANGED
@@ -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
|
-
|
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!
|
data/lib/hygroscope/template.rb
CHANGED
@@ -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.
|
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
|
11
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|