kumogata 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/kumogata/argument_parser.rb +4 -0
- data/lib/kumogata/client.rb +47 -8
- data/lib/kumogata/version.rb +1 -1
- data/spec/kumogata_show_events_spec.rb +49 -0
- data/spec/kumogata_show_outputs_spec.rb +1 -1
- data/spec/kumogata_show_resources_spec.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f3941d2e08255324b58a9db11ab3365d7fc4352
|
4
|
+
data.tar.gz: a7de79d6681d01a8ff16176da2fcfae3aa75ccc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 754de61cabe8e01e4b9e2ba2a73859615fb43d8846d70a90ff19d04c25743e5494ca59dc92a662eb1380e1ec7b1bac868e41b0e9c7cf276e51410a164bf9c605
|
7
|
+
data.tar.gz: 2d13045023a54b098dca9d11e94223066c6594947154b5f5b20be84f5c326d67d1762347db717e88c158f3467038dcb8e06ef2c52ed181478f9fcc840340c067
|
data/README.md
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|
|
6
6
|
Kumogata is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformation/).
|
7
7
|
|
8
|
-
[![Gem Version](https://badge.fury.io/rb/kumogata.png?
|
9
|
-
[![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/kumogata.png?201403061551)](http://badge.fury.io/rb/kumogata)
|
9
|
+
[![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403061551)](https://drone.io/github.com/winebarrel/kumogata/latest)
|
10
10
|
|
11
11
|
It can define a template in Ruby DSL, such as:
|
12
12
|
|
@@ -71,6 +71,7 @@ Commands:
|
|
71
71
|
delete STACK_NAME Delete a specified stack
|
72
72
|
list [STACK_NAME] List summary information for stacks
|
73
73
|
export STACK_NAME Export a template from a specified stack
|
74
|
+
show-events STACK_NAME Show events for a specified stack
|
74
75
|
show-outputs STACK_NAME Show outputs for a specified stack
|
75
76
|
show-resources STACK_NAME Show resources for a specified stack
|
76
77
|
diff PATH_OR_URL1 PATH_OR_URL2 Compare templates logically
|
@@ -38,6 +38,10 @@ class Kumogata::ArgumentParser
|
|
38
38
|
:description => 'Export a template from a specified stack',
|
39
39
|
:arguments => [:stack_name]
|
40
40
|
},
|
41
|
+
:'show-events' => {
|
42
|
+
:description => 'Show events for a specified stack',
|
43
|
+
:arguments => [:stack_name]
|
44
|
+
},
|
41
45
|
:'show-outputs' => {
|
42
46
|
:description => 'Show outputs for a specified stack',
|
43
47
|
:arguments => [:stack_name]
|
data/lib/kumogata/client.rb
CHANGED
@@ -62,6 +62,11 @@ class Kumogata::Client
|
|
62
62
|
devaluate_template(template).chomp
|
63
63
|
end
|
64
64
|
|
65
|
+
def show_events(stack_name)
|
66
|
+
events = describe_events(stack_name)
|
67
|
+
JSON.pretty_generate(events)
|
68
|
+
end
|
69
|
+
|
65
70
|
def show_outputs(stack_name)
|
66
71
|
outputs = describe_outputs(stack_name)
|
67
72
|
JSON.pretty_generate(outputs)
|
@@ -192,7 +197,7 @@ class Kumogata::Client
|
|
192
197
|
unless while_in_progress(stack, 'CREATE_COMPLETE')
|
193
198
|
errmsgs = ['Create failed']
|
194
199
|
errmsgs << stack_name
|
195
|
-
errmsgs <<
|
200
|
+
errmsgs << stack.status_reason if stack.status_reason
|
196
201
|
raise errmsgs.join(': ')
|
197
202
|
end
|
198
203
|
|
@@ -216,7 +221,7 @@ class Kumogata::Client
|
|
216
221
|
unless while_in_progress(stack, 'UPDATE_COMPLETE')
|
217
222
|
errmsgs = ['Update failed']
|
218
223
|
errmsgs << stack_name
|
219
|
-
errmsgs <<
|
224
|
+
errmsgs << stack.status_reason if stack.status_reason
|
220
225
|
raise errmsgs.join(': ')
|
221
226
|
end
|
222
227
|
|
@@ -245,7 +250,7 @@ class Kumogata::Client
|
|
245
250
|
unless completed
|
246
251
|
errmsgs = ['Delete failed']
|
247
252
|
errmsgs << stack_name
|
248
|
-
errmsgs <<
|
253
|
+
errmsgs << stack.status_reason if stack.status_reason
|
249
254
|
raise errmsgs.join(': ')
|
250
255
|
end
|
251
256
|
end
|
@@ -272,6 +277,14 @@ class Kumogata::Client
|
|
272
277
|
JSON.parse(stack.template)
|
273
278
|
end
|
274
279
|
|
280
|
+
def describe_events(stack_name)
|
281
|
+
AWS.memoize do
|
282
|
+
stack = @cloud_formation.stacks[stack_name]
|
283
|
+
stack.status
|
284
|
+
events_for(stack)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
275
288
|
def describe_outputs(stack_name)
|
276
289
|
AWS.memoize do
|
277
290
|
stack = @cloud_formation.stacks[stack_name]
|
@@ -339,6 +352,30 @@ class Kumogata::Client
|
|
339
352
|
Kumogata.logger.info('Template validated successfully'.green)
|
340
353
|
end
|
341
354
|
|
355
|
+
def events_for(stack)
|
356
|
+
stack.events.map do |event|
|
357
|
+
event_hash = {}
|
358
|
+
|
359
|
+
[
|
360
|
+
:event_id,
|
361
|
+
:logical_resource_id,
|
362
|
+
:physical_resource_id,
|
363
|
+
:resource_properties,
|
364
|
+
:resource_status,
|
365
|
+
:resource_status_reason,
|
366
|
+
:resource_type,
|
367
|
+
:stack,
|
368
|
+
:stack_id,
|
369
|
+
:stack_name,
|
370
|
+
:timestamp,
|
371
|
+
].each do |k|
|
372
|
+
event_hash[camelize(k)] = event.send(k)
|
373
|
+
end
|
374
|
+
|
375
|
+
event_hash
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
342
379
|
def outputs_for(stack)
|
343
380
|
outputs_hash = {}
|
344
381
|
|
@@ -361,11 +398,7 @@ class Kumogata::Client
|
|
361
398
|
:resource_status_reason,
|
362
399
|
:last_updated_timestamp
|
363
400
|
].each do |k|
|
364
|
-
|
365
|
-
i[0, 1].upcase + i[1..-1].downcase
|
366
|
-
}.join
|
367
|
-
|
368
|
-
summary_hash[camelcase] = summary[k]
|
401
|
+
summary_hash[camelize(k)] = summary[k]
|
369
402
|
end
|
370
403
|
|
371
404
|
summary_hash
|
@@ -392,4 +425,10 @@ Stack Resource Summaries:
|
|
392
425
|
})
|
393
426
|
end
|
394
427
|
end
|
428
|
+
|
429
|
+
def camelize(str)
|
430
|
+
str.to_s.split(/[-_]/).map {|i|
|
431
|
+
i[0, 1].upcase + i[1..-1].downcase
|
432
|
+
}.join
|
433
|
+
end
|
395
434
|
end
|
data/lib/kumogata/version.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
describe 'Kumogata::Client#show_events' do
|
2
|
+
it 'show events' do
|
3
|
+
|
4
|
+
resources = run_client(:show_events, :arguments => ['MyStack']) do |client, cf|
|
5
|
+
event = make_double('event') do |obj|
|
6
|
+
obj.should_receive(:event_id) { "f45e6070-a4f7-11e3-9326-5088487c4896" }
|
7
|
+
obj.should_receive(:logical_resource_id) { "kumogata-f11118a4-a4f7-11e3-8183-98fe943e66ca" }
|
8
|
+
obj.should_receive(:physical_resource_id) { "arn:aws:cloudformation:ap-northeast-1:822997939312:stack/kumogata-f11118a4-a4f7-11e3-8183-98fe943e66ca/f1381a30-a4f7-11e3-a340-506cf9a1c096" }
|
9
|
+
obj.should_receive(:resource_properties) { nil }
|
10
|
+
obj.should_receive(:resource_status) { "CREATE_FAILED" }
|
11
|
+
obj.should_receive(:resource_status_reason) { "The following resource(s) failed to create: [myEC2Instance]. " }
|
12
|
+
obj.should_receive(:resource_type) { "AWS::CloudFormation::Stack" }
|
13
|
+
obj.should_receive(:stack) { "#<AWS::CloudFormation::Stack:0x007ffe4384ca80>" }
|
14
|
+
obj.should_receive(:stack_id) { "arn:aws:cloudformation:ap-northeast-1:822997939312:stack/kumogata-f11118a4-a4f7-11e3-8183-98fe943e66ca/f1381a30-a4f7-11e3-a340-506cf9a1c096" }
|
15
|
+
obj.should_receive(:stack_name) { "kumogata-f11118a4-a4f7-11e3-8183-98fe943e66ca" }
|
16
|
+
obj.should_receive(:timestamp) { "2014-03-06 06:24:21 UTC" }
|
17
|
+
end
|
18
|
+
|
19
|
+
stack = make_double('stack') do |obj|
|
20
|
+
obj.should_receive(:status) { 'CREATE_COMPLETE' }
|
21
|
+
obj.should_receive(:events).and_return([event])
|
22
|
+
end
|
23
|
+
|
24
|
+
stacks = make_double('stacks') do |obj|
|
25
|
+
obj.should_receive(:[]).with('MyStack') { stack }
|
26
|
+
end
|
27
|
+
|
28
|
+
cf.should_receive(:stacks) { stacks }
|
29
|
+
end
|
30
|
+
|
31
|
+
expect(resources).to eq((<<-EOS).chomp)
|
32
|
+
[
|
33
|
+
{
|
34
|
+
"EventId": "f45e6070-a4f7-11e3-9326-5088487c4896",
|
35
|
+
"LogicalResourceId": "kumogata-f11118a4-a4f7-11e3-8183-98fe943e66ca",
|
36
|
+
"PhysicalResourceId": "arn:aws:cloudformation:ap-northeast-1:822997939312:stack/kumogata-f11118a4-a4f7-11e3-8183-98fe943e66ca/f1381a30-a4f7-11e3-a340-506cf9a1c096",
|
37
|
+
"ResourceProperties": null,
|
38
|
+
"ResourceStatus": "CREATE_FAILED",
|
39
|
+
"ResourceStatusReason": "The following resource(s) failed to create: [myEC2Instance]. ",
|
40
|
+
"ResourceType": "AWS::CloudFormation::Stack",
|
41
|
+
"Stack": "#<AWS::CloudFormation::Stack:0x007ffe4384ca80>",
|
42
|
+
"StackId": "arn:aws:cloudformation:ap-northeast-1:822997939312:stack/kumogata-f11118a4-a4f7-11e3-8183-98fe943e66ca/f1381a30-a4f7-11e3-a340-506cf9a1c096",
|
43
|
+
"StackName": "kumogata-f11118a4-a4f7-11e3-8183-98fe943e66ca",
|
44
|
+
"Timestamp": "2014-03-06 06:24:21 UTC"
|
45
|
+
}
|
46
|
+
]
|
47
|
+
EOS
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kumogata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- spec/kumogata_diff_spec.rb
|
198
198
|
- spec/kumogata_export_spec.rb
|
199
199
|
- spec/kumogata_list_spec.rb
|
200
|
+
- spec/kumogata_show_events_spec.rb
|
200
201
|
- spec/kumogata_show_outputs_spec.rb
|
201
202
|
- spec/kumogata_show_resources_spec.rb
|
202
203
|
- spec/kumogata_update_spec.rb
|
@@ -235,6 +236,7 @@ test_files:
|
|
235
236
|
- spec/kumogata_diff_spec.rb
|
236
237
|
- spec/kumogata_export_spec.rb
|
237
238
|
- spec/kumogata_list_spec.rb
|
239
|
+
- spec/kumogata_show_events_spec.rb
|
238
240
|
- spec/kumogata_show_outputs_spec.rb
|
239
241
|
- spec/kumogata_show_resources_spec.rb
|
240
242
|
- spec/kumogata_update_spec.rb
|