kumogata 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 58505fd69f4767540e2830de48d42a07605781d9
4
- data.tar.gz: dbed8f02373d8f06f284009b9c3e0b4126b4bf10
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGM5NjA4MDkxMGZlOGNlNjZiNGFjZjMwZGU1Mzg5YTg5YWQ5NGEwMQ==
5
+ data.tar.gz: !binary |-
6
+ ZDY4YmYzOWUzMzcyMzEwNjZlNjNjMzU2MWEzMWJkZWNjN2JmYjcxMA==
5
7
  SHA512:
6
- metadata.gz: db73cef84452369b64bc6284f65672120b4f62720c6ac9abcb92cf6bfc26dfe5709035a11aaeca72a7cd6788d09aa1cea2b30ea710f63390fde352996543b0d6
7
- data.tar.gz: e40c5f04d96bafbf34f721a4f46f116ac65786fdc4f7c308d330dbb85e826592ea3929d60720311716cacfef9ab486b0a4ed09b64859ae9af2822016173e647e
8
+ metadata.gz: !binary |-
9
+ YTgzYzQ4MzA4ZWQyNGNlNmYyZGY1ZjIxODZlNTAxZDIzNDc1ZmVhZmMyYTUw
10
+ MDBlNjNmOWJkYWQ3OTE1OTNhZDg3NzNkNWU2MWM2MjBlNDM4NDJmNTQxMmNm
11
+ YmIxY2M1ZTJjNjRiNDFiYTUxOTM2NDUwNGIxZGMxMDYyZGI1ZDM=
12
+ data.tar.gz: !binary |-
13
+ ZmZjNTEzZDk4ZTU1YzkyZjAwZGVjNDVhNjYyYjU3YzdjYmRiY2U1N2RjN2Iw
14
+ NjA2NmY4ZjExMmM5MmFhYmQzZjI4NDQ4Mzc2YTQ3MmMxNmFhMDM1ZTVlMGE5
15
+ M2I1NzgxODlkYzkyY2E0MjdlYmQ2MTFlMGQyNjg4MzAwMTNlODk=
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Kumogata
2
2
 
3
- Kumogata is a tool for AWS CroudFormation.
3
+ Kumogata is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformation/).
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403030250)](http://badge.fury.io/rb/kumogata)
6
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403030250)](https://drone.io/github.com/winebarrel/kumogata/latest)
5
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403031324)](http://badge.fury.io/rb/kumogata)
6
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403031324)](https://drone.io/github.com/winebarrel/kumogata/latest)
7
7
 
8
8
  It can define a template in Ruby DSL, such as:
9
9
 
@@ -42,6 +42,8 @@ Outputs do
42
42
  end
43
43
  ```
44
44
 
45
+ Ruby template structure is almost the same as [JSON template](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-structure.html).
46
+
45
47
  ## Installation
46
48
 
47
49
  $ gem install kumogata
@@ -52,13 +54,15 @@ end
52
54
  Usage: kumogata <command> [args] [options]
53
55
 
54
56
  Commands:
55
- create PATH_OR_URL [STACK_NAME] Create resources as specified in the template
56
- validate PATH_OR_URL Validate a specified template
57
- convert PATH_OR_URL Convert a template format
58
- update PATH_OR_URL STACK_NAME Update a stack as specified in the template
59
- delete STACK_NAME Delete a specified stack
60
- list [STACK_NAME] List summary information for stacks
61
- export STACK_NAME Export a template from a specified stack
57
+ create PATH_OR_URL [STACK_NAME] Create resources as specified in the template
58
+ validate PATH_OR_URL Validate a specified template
59
+ convert PATH_OR_URL Convert a template format
60
+ update PATH_OR_URL STACK_NAME Update a stack as specified in the template
61
+ delete STACK_NAME Delete a specified stack
62
+ list [STACK_NAME] List summary information for stacks
63
+ export STACK_NAME Export a template from a specified stack
64
+ show-outputs STACK_NAME Show outputs for a specified stack
65
+ show-resources STACK_NAME Show resources for a specified stack
62
66
 
63
67
  Options:
64
68
  -k, --access-key ACCESS_KEY
@@ -79,15 +83,15 @@ Options:
79
83
 
80
84
  ### Create resources
81
85
 
82
- $ kumogata creat template.rb
86
+ $ kumogata create template.rb
83
87
 
84
88
  If you want to save the stack, please specify the stack name:
85
89
 
86
- $ kumogata creat template.rb any_stack_name
90
+ $ kumogata create template.rb any_stack_name
87
91
 
88
92
  If you want to pass parameters, please use `-p` option:
89
93
 
90
- $ kumogata creat template.rb -p "InstanceType=m1.large,KeyName=any_other_key"
94
+ $ kumogata create template.rb -p "InstanceType=m1.large,KeyName=any_other_key"
91
95
 
92
96
 
93
97
  **Notice**
data/kumogata.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Kumogata::VERSION
9
9
  spec.authors = ['Genki Sugawara']
10
10
  spec.email = ['sgwr_dts@yahoo.co.jp']
11
- spec.summary = %q{A tool for AWS CroudFormation.}
12
- spec.description = %q{A tool for AWS CroudFormation. It can define a template in Ruby DSL.}
11
+ spec.summary = %q{A tool for AWS CloudFormation.}
12
+ spec.description = %q{A tool for AWS CloudFormation. It can define a template in Ruby DSL.}
13
13
  spec.homepage = 'https://github.com/winebarrel/kumogata'
14
14
  spec.license = 'MIT'
15
15
 
@@ -38,6 +38,14 @@ class Kumogata::ArgumentParser
38
38
  :description => 'Export a template from a specified stack',
39
39
  :arguments => [:stack_name]
40
40
  },
41
+ :'show-outputs' => {
42
+ :description => 'Show outputs for a specified stack',
43
+ :arguments => [:stack_name]
44
+ },
45
+ :'show-resources' => {
46
+ :description => 'Show resources for a specified stack',
47
+ :arguments => [:stack_name]
48
+ },
41
49
  }
42
50
 
43
51
  class << self
@@ -97,6 +105,7 @@ class Kumogata::ArgumentParser
97
105
  end
98
106
  end
99
107
 
108
+ command = command.to_s.gsub('-', '_').to_sym
100
109
  [command, arguments, options]
101
110
  end
102
111
 
@@ -57,11 +57,21 @@ class Kumogata::Client
57
57
  JSON.pretty_generate(stacks)
58
58
  end
59
59
 
60
- def export(stack_name = nil)
60
+ def export(stack_name)
61
61
  template = export_template(stack_name)
62
62
  devaluate_template(template).chomp
63
63
  end
64
64
 
65
+ def show_outputs(stack_name)
66
+ outputs = describe_outputs(stack_name)
67
+ JSON.pretty_generate(outputs)
68
+ end
69
+
70
+ def show_resources(stack_name)
71
+ resources = describe_resources(stack_name)
72
+ JSON.pretty_generate(resources)
73
+ end
74
+
65
75
  private ###########################################################
66
76
 
67
77
  def open_template(path_or_url)
@@ -240,6 +250,22 @@ class Kumogata::Client
240
250
  JSON.parse(stack.template)
241
251
  end
242
252
 
253
+ def describe_outputs(stack_name)
254
+ AWS.memoize do
255
+ stack = @cloud_formation.stacks[stack_name]
256
+ stack.status
257
+ outputs_for(stack)
258
+ end
259
+ end
260
+
261
+ def describe_resources(stack_name)
262
+ AWS.memoize do
263
+ stack = @cloud_formation.stacks[stack_name]
264
+ stack.status
265
+ resource_summaries_for(stack)
266
+ end
267
+ end
268
+
243
269
  def while_in_progress(stack, complete_status)
244
270
  while stack.status =~ /_IN_PROGRESS\Z/
245
271
  print '.'.intense_black unless @options.debug?
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -22,7 +22,7 @@ describe 'Kumogata::Client#export' do
22
22
  }
23
23
  }
24
24
  }
25
- EOS
25
+ EOS
26
26
 
27
27
  template = run_client(:export, :arguments => ['MyStack']) do |client, cf|
28
28
  stack = make_double('stack') do |obj|
@@ -0,0 +1,28 @@
1
+ describe 'Kumogata::Client#outputs' do
2
+ it 'show outputs' do
3
+
4
+ outputs = run_client(:show_outputs, :arguments => ['MyStack']) do |client, cf|
5
+ output = make_double('output') do |obj|
6
+ obj.should_receive(:key) { 'AZ' }
7
+ obj.should_receive(:value) { 'ap-northeast-1a' }
8
+ end
9
+
10
+ stack = make_double('stack') do |obj|
11
+ obj.should_receive(:status) { 'CREATE_COMPLETE' }
12
+ obj.should_receive(:outputs) { [output] }
13
+ end
14
+
15
+ stacks = make_double('stacks') do |obj|
16
+ obj.should_receive(:[]).with('MyStack') { stack }
17
+ end
18
+
19
+ cf.should_receive(:stacks) { stacks }
20
+ end
21
+
22
+ expect(outputs).to eq((<<-EOS).chomp)
23
+ {
24
+ "AZ": "ap-northeast-1a"
25
+ }
26
+ EOS
27
+ end
28
+ end
@@ -0,0 +1,39 @@
1
+ describe 'Kumogata::Client#resources' do
2
+ it 'show resources' do
3
+
4
+ resources = run_client(:show_resources, :arguments => ['MyStack']) do |client, cf|
5
+ stack = make_double('stack') do |obj|
6
+ obj.should_receive(:status) { 'CREATE_COMPLETE' }
7
+ obj.should_receive(:resource_summaries).and_return([
8
+ {
9
+ :logical_resource_id => 'myEC2Instance',
10
+ :physical_resource_id => 'i-XXXXXXXX',
11
+ :resource_type => 'AWS::EC2::Instance',
12
+ :resource_status => 'CREATE_COMPLETE',
13
+ :resource_status_reason => nil,
14
+ :last_updated_timestamp => '2014-03-03 04:04:40 UTC',
15
+ }
16
+ ])
17
+ end
18
+
19
+ stacks = make_double('stacks') do |obj|
20
+ obj.should_receive(:[]).with('MyStack') { stack }
21
+ end
22
+
23
+ cf.should_receive(:stacks) { stacks }
24
+ end
25
+
26
+ expect(resources).to eq((<<-EOS).chomp)
27
+ [
28
+ {
29
+ "LogicalResourceId": "myEC2Instance",
30
+ "PhysicalResourceId": "i-XXXXXXXX",
31
+ "ResourceType": "AWS::EC2::Instance",
32
+ "ResourceStatus": "CREATE_COMPLETE",
33
+ "ResourceStatusReason": null,
34
+ "LastUpdatedTimestamp": "2014-03-03 04:04:40 UTC"
35
+ }
36
+ ]
37
+ EOS
38
+ end
39
+ end
metadata CHANGED
@@ -1,156 +1,156 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumogata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-02 00:00:00.000000000 Z
11
+ date: 2014-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dslh
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.2.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.2.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hashie
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: highline
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: term-ansicolor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: uuidtools
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ! '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: bundler
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ! '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ! '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rake
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ! '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ! '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ! '>='
144
144
  - !ruby/object:Gem::Version
145
145
  version: 2.11.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ! '>='
151
151
  - !ruby/object:Gem::Version
152
152
  version: 2.11.0
153
- description: A tool for AWS CroudFormation. It can define a template in Ruby DSL.
153
+ description: A tool for AWS CloudFormation. It can define a template in Ruby DSL.
154
154
  email:
155
155
  - sgwr_dts@yahoo.co.jp
156
156
  executables:
@@ -179,6 +179,8 @@ files:
179
179
  - spec/kumogata_delete_spec.rb
180
180
  - spec/kumogata_export_spec.rb
181
181
  - spec/kumogata_list_spec.rb
182
+ - spec/kumogata_show_outputs_spec.rb
183
+ - spec/kumogata_show_resources_spec.rb
182
184
  - spec/kumogata_update_spec.rb
183
185
  - spec/kumogata_validate_spec.rb
184
186
  - spec/spec_helper.rb
@@ -192,27 +194,28 @@ require_paths:
192
194
  - lib
193
195
  required_ruby_version: !ruby/object:Gem::Requirement
194
196
  requirements:
195
- - - '>='
197
+ - - ! '>='
196
198
  - !ruby/object:Gem::Version
197
199
  version: '0'
198
200
  required_rubygems_version: !ruby/object:Gem::Requirement
199
201
  requirements:
200
- - - '>='
202
+ - - ! '>='
201
203
  - !ruby/object:Gem::Version
202
204
  version: '0'
203
205
  requirements: []
204
206
  rubyforge_project:
205
- rubygems_version: 2.0.14
207
+ rubygems_version: 2.1.11
206
208
  signing_key:
207
209
  specification_version: 4
208
- summary: A tool for AWS CroudFormation.
210
+ summary: A tool for AWS CloudFormation.
209
211
  test_files:
210
212
  - spec/kumogata_convert_spec.rb
211
213
  - spec/kumogata_create_spec.rb
212
214
  - spec/kumogata_delete_spec.rb
213
215
  - spec/kumogata_export_spec.rb
214
216
  - spec/kumogata_list_spec.rb
217
+ - spec/kumogata_show_outputs_spec.rb
218
+ - spec/kumogata_show_resources_spec.rb
215
219
  - spec/kumogata_update_spec.rb
216
220
  - spec/kumogata_validate_spec.rb
217
221
  - spec/spec_helper.rb
218
- has_rdoc: