awful 0.0.124 → 0.0.125
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 +4 -4
- data/bin/apigw +3 -0
- data/lib/awful/api_gateway_methods.rb +27 -0
- data/lib/awful/api_gateway_resources.rb +33 -0
- data/lib/awful/api_gateway_stages.rb +32 -0
- data/lib/awful/cloudformation.rb +35 -24
- data/lib/awful/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 344579f6b39568f6f3c56f62baad2d3c8a31cc61
|
4
|
+
data.tar.gz: fb71401f43a220dabe1a6275ceb3c32992715a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc6f9ae6a2b727b69604e8239802ba082a33731edee4c6d5486f22536d043aa29f12c90cf249d916881d2ca54a9c3c3e103383ec712ee0c38d1a03972ef928bf
|
7
|
+
data.tar.gz: 95a417937a0068dc135ede81034a0e992559ff0b324cc90401b63c1d5d0088a19408cbef3a2ad3f3d904e53fcd36ba67e628731d1f3167d03a63dca1a6f92e84
|
data/bin/apigw
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Awful
|
2
|
+
module Short
|
3
|
+
def apimethods(*args)
|
4
|
+
Awful::ApiGateway::Methods.new.invoke(*args)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module ApiGateway
|
9
|
+
|
10
|
+
class Methods < Cli
|
11
|
+
desc 'dump REST_API_ID', 'list methods for given rest api and resource'
|
12
|
+
method_option :method, aliases: '-m', default: 'GET', desc: 'HTTP method to get'
|
13
|
+
def dump(id, resource)
|
14
|
+
api_gateway.get_method(rest_api_id: id, resource_id: resource, http_method: options[:method]).output do |response|
|
15
|
+
puts YAML.dump(stringify_keys(response.to_hash))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class RestApi < Cli
|
22
|
+
desc 'methods', 'methods subcommands'
|
23
|
+
subcommand 'methods', Methods
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Awful
|
2
|
+
module Short
|
3
|
+
def apiresources(*args)
|
4
|
+
Awful::ApiGateway::Resources.new.invoke(*args)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module ApiGateway
|
9
|
+
|
10
|
+
class Resources < Cli
|
11
|
+
desc 'ls REST_API_ID', 'list resources for given rest api'
|
12
|
+
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
13
|
+
def ls(id)
|
14
|
+
api_gateway.get_resources(rest_api_id: id).items.output do |items|
|
15
|
+
if options[:long]
|
16
|
+
print_table items.map { |i|
|
17
|
+
methods = i.resource_methods ? i.resource_methods.keys.join(',') : ''
|
18
|
+
[i.path, i.id, i.parent_id, methods]
|
19
|
+
}.sort
|
20
|
+
else
|
21
|
+
puts items.map(&:path).sort
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class RestApi < Cli
|
28
|
+
desc 'resources', 'resources subcommands'
|
29
|
+
subcommand 'resources', Resources
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Awful
|
2
|
+
module Short
|
3
|
+
def apistages(*args)
|
4
|
+
Awful::ApiGateway::Stages.new.invoke(*args)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module ApiGateway
|
9
|
+
|
10
|
+
class Stages < Cli
|
11
|
+
desc 'ls REST_API_ID', 'list stages for given rest api'
|
12
|
+
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
13
|
+
def ls(id, deployment = nil)
|
14
|
+
api_gateway.get_stages(rest_api_id: id, deployment_id: deployment).item.output do |items|
|
15
|
+
if options[:long]
|
16
|
+
print_table items.map { |i|
|
17
|
+
[i.stage_name, i.deployment_id, i.last_updated_date, i.description]
|
18
|
+
}.sort
|
19
|
+
else
|
20
|
+
puts items.map(&:stage_name).sort
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class RestApi < Cli
|
27
|
+
desc 'stages', 'stages subcommands'
|
28
|
+
subcommand 'stages', Stages
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/awful/cloudformation.rb
CHANGED
@@ -56,11 +56,9 @@ module Awful
|
|
56
56
|
end
|
57
57
|
|
58
58
|
## match on given arg
|
59
|
-
stacks
|
59
|
+
stacks.select do |stack|
|
60
60
|
stack.stack_name.match(name)
|
61
|
-
end
|
62
|
-
|
63
|
-
stacks.tap do |list|
|
61
|
+
end.output do |list|
|
64
62
|
if options[:long]
|
65
63
|
print_table list.map { |s|
|
66
64
|
[
|
@@ -88,29 +86,29 @@ module Awful
|
|
88
86
|
|
89
87
|
desc 'dump NAME', 'describe stack named NAME'
|
90
88
|
def dump(name)
|
91
|
-
cf.describe_stacks(stack_name: name).stacks.
|
89
|
+
cf.describe_stacks(stack_name: name).stacks.output do |stacks|
|
92
90
|
stacks.each do |stack|
|
93
91
|
puts YAML.dump(stringify_keys(stack.to_hash))
|
94
92
|
end
|
95
93
|
end
|
96
94
|
end
|
97
95
|
|
98
|
-
desc 'outputs NAME', 'get stack outputs as a hash'
|
99
|
-
def outputs(name)
|
100
|
-
cf.describe_stacks(stack_name: name).stacks.
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
96
|
+
desc 'outputs NAME [KEY]', 'get stack outputs as a ruby hash, or individual value'
|
97
|
+
def outputs(name, key = nil)
|
98
|
+
output_hash = cf.describe_stacks(stack_name: name).stacks.first.outputs.each_with_object({}) do |o, hash|
|
99
|
+
hash[o.output_key] = o.output_value
|
100
|
+
end
|
101
|
+
|
102
|
+
if key
|
103
|
+
output_hash[key.to_s].output(&method(:puts))
|
104
|
+
else
|
105
|
+
output_hash.output(&method(:print_table))
|
108
106
|
end
|
109
107
|
end
|
110
108
|
|
111
109
|
desc 'template NAME', 'get template for stack named NAME'
|
112
110
|
def template(name)
|
113
|
-
cf.get_template(stack_name: name).template_body.
|
111
|
+
cf.get_template(stack_name: name).template_body.output do |template|
|
114
112
|
puts template
|
115
113
|
end
|
116
114
|
end
|
@@ -118,17 +116,17 @@ module Awful
|
|
118
116
|
desc 'validate FILE', 'validate given template in FILE or stdin'
|
119
117
|
def validate(file = nil)
|
120
118
|
begin
|
121
|
-
cf.validate_template(template_body: file_or_stdin(file)).
|
119
|
+
cf.validate_template(template_body: file_or_stdin(file)).output do |response|
|
122
120
|
puts YAML.dump(stringify_keys(response.to_hash))
|
123
121
|
end
|
124
122
|
rescue Aws::CloudFormation::Errors::ValidationError => e
|
125
|
-
e.
|
123
|
+
e.output { |err| puts err.message }
|
126
124
|
end
|
127
125
|
end
|
128
126
|
|
129
127
|
desc 'create NAME', 'create stack with name NAME'
|
130
128
|
def create(name, file = nil)
|
131
|
-
cf.create_stack(stack_name: name, template_body: file_or_stdin(file)).
|
129
|
+
cf.create_stack(stack_name: name, template_body: file_or_stdin(file)).output do |response|
|
132
130
|
puts response.stack_id
|
133
131
|
end
|
134
132
|
end
|
@@ -136,11 +134,11 @@ module Awful
|
|
136
134
|
desc 'update NAME', 'update stack with name NAME'
|
137
135
|
def update(name, file = nil)
|
138
136
|
begin
|
139
|
-
cf.update_stack(stack_name: name, template_body: file_or_stdin(file)).
|
137
|
+
cf.update_stack(stack_name: name, template_body: file_or_stdin(file)).output do |response|
|
140
138
|
puts response.stack_id
|
141
139
|
end
|
142
140
|
rescue Aws::CloudFormation::Errors::ValidationError => e
|
143
|
-
e.
|
141
|
+
e.output { |err| puts err.message }
|
144
142
|
end
|
145
143
|
end
|
146
144
|
|
@@ -156,7 +154,7 @@ module Awful
|
|
156
154
|
{key: key, value: value}
|
157
155
|
end
|
158
156
|
}
|
159
|
-
cf.update_stack(params).
|
157
|
+
cf.update_stack(params).output do |response|
|
160
158
|
puts response.stack_id
|
161
159
|
end
|
162
160
|
end
|
@@ -225,16 +223,29 @@ module Awful
|
|
225
223
|
if policy
|
226
224
|
cf.set_stack_policy(stack_name: name, stack_policy_body: policy)
|
227
225
|
else
|
228
|
-
cf.get_stack_policy(stack_name: name).stack_policy_body.
|
226
|
+
cf.get_stack_policy(stack_name: name).stack_policy_body.output(&method(:puts))
|
229
227
|
end
|
230
228
|
end
|
231
229
|
|
232
230
|
desc 'limits', 'describe cloudformation account limits'
|
233
231
|
def limits
|
234
|
-
cf.describe_account_limits.account_limits.
|
232
|
+
cf.describe_account_limits.account_limits.output do |limits|
|
235
233
|
print_table limits.map { |l| [l.name, l.value] }
|
236
234
|
end
|
237
235
|
end
|
238
236
|
|
237
|
+
## this is almost entirely useless in practice
|
238
|
+
desc 'cost', 'describe cost for given stack'
|
239
|
+
def cost(name)
|
240
|
+
template = cf.get_template(stack_name: name).template_body
|
241
|
+
parameters = cf.describe_stacks(stack_name: name).stacks.first.parameters.map do |p|
|
242
|
+
{
|
243
|
+
parameter_key: p.parameter_key,
|
244
|
+
parameter_value: p.parameter_value,
|
245
|
+
use_previous_value: true, # use param values from actual stack
|
246
|
+
}
|
247
|
+
end
|
248
|
+
puts cf.estimate_template_cost(template_body: template, parameters: parameters).url
|
249
|
+
end
|
239
250
|
end
|
240
251
|
end
|
data/lib/awful/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.125
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -153,6 +153,9 @@ files:
|
|
153
153
|
- lib/awful/ami.rb
|
154
154
|
- lib/awful/api_gateway.rb
|
155
155
|
- lib/awful/api_gateway_deployments.rb
|
156
|
+
- lib/awful/api_gateway_methods.rb
|
157
|
+
- lib/awful/api_gateway_resources.rb
|
158
|
+
- lib/awful/api_gateway_stages.rb
|
156
159
|
- lib/awful/auto_scaling.rb
|
157
160
|
- lib/awful/auto_scaling_notifications.rb
|
158
161
|
- lib/awful/changesets.rb
|