awful 0.0.139 → 0.0.140
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/alb +7 -0
- data/lib/awful/alb.rb +87 -0
- data/lib/awful/ecs.rb +23 -0
- data/lib/awful/ssm.rb +4 -4
- 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: 66c22e626406819242c9acc7c78fb4c77e94b8f2
|
4
|
+
data.tar.gz: 27b295d708c26242d403df60b7a76fe3d61e3aef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdecb010ceaa9ad0bfdafbc53eac13796420889c604a41b6fd215ed7a84c1037a87e9aaa054096b25607b9ba7e47f717fc1d12e63c947cf048499e6311a2b2b0
|
7
|
+
data.tar.gz: 38019975c26582feaa932a8efb8020000f47c4911b1c10aa3b64fe5fe8f73715e67b08d8022f254dfc445586a6e09ae954430f5d3a491b6df7da93353ab4f7f1
|
data/bin/alb
ADDED
data/lib/awful/alb.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
module Awful
|
2
|
+
module Short
|
3
|
+
def alb(*args)
|
4
|
+
Awful::Alb.new.invoke(*args)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class Alb < Cli
|
9
|
+
COLORS = {
|
10
|
+
active: :green,
|
11
|
+
provisioning: :yellow,
|
12
|
+
failed: :red,
|
13
|
+
InService: :green,
|
14
|
+
OutOfService: :red,
|
15
|
+
}
|
16
|
+
|
17
|
+
no_commands do
|
18
|
+
def color(string)
|
19
|
+
set_color(string, COLORS.fetch(string.to_sym, :yellow))
|
20
|
+
end
|
21
|
+
|
22
|
+
def alb
|
23
|
+
@alb ||= Aws::ElasticLoadBalancingV2::Client.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def describe_load_balancers(*names)
|
27
|
+
next_marker = nil
|
28
|
+
albs = []
|
29
|
+
loop do
|
30
|
+
response = alb.describe_load_balancers(names: names, marker: next_marker)
|
31
|
+
albs += response.load_balancers
|
32
|
+
next_marker = response.next_marker
|
33
|
+
break unless next_marker
|
34
|
+
end
|
35
|
+
albs
|
36
|
+
end
|
37
|
+
|
38
|
+
## return ARN for named ALB
|
39
|
+
def get_arn(name_or_arn)
|
40
|
+
if name_or_arn.start_with?('arn:')
|
41
|
+
name_or_arn # it is already an arn
|
42
|
+
else
|
43
|
+
describe_load_balancers(name_or_arn).first.load_balancer_arn
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'ls [NAMES]', 'list application load-balancers'
|
49
|
+
method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
|
50
|
+
method_option :matching, aliases: '-m', type: :string, default: nil, desc: 'return matching ALB names'
|
51
|
+
def ls(*names)
|
52
|
+
describe_load_balancers(*names).tap do |albs|
|
53
|
+
albs.select! { |a| a.load_balancer_name.match(options[:matching]) } if options[:matching]
|
54
|
+
end.output do |list|
|
55
|
+
if options[:long]
|
56
|
+
print_table list.map { |a| [a.load_balancer_name, a.dns_name, color(a.state.code), a.vpc_id, a.created_time] }
|
57
|
+
else
|
58
|
+
puts list.map(&:load_balancer_name)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'dump NAMES', 'dump ALB details'
|
64
|
+
def dump(*names)
|
65
|
+
describe_load_balancers(*names).output do |albs|
|
66
|
+
albs.each do |alb|
|
67
|
+
puts YAML.dump(stringify_keys(alb.to_hash))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc 'listeners NAME', 'list listeners for ALB with NAME'
|
73
|
+
method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
|
74
|
+
def listeners(name)
|
75
|
+
alb.describe_listeners(load_balancer_arn: get_arn(name)).listeners.output do |listeners|
|
76
|
+
if options[:long]
|
77
|
+
print_table listeners.map { |l|
|
78
|
+
[l.protocol, l.port, l.ssl_policy, l.certificates.join(','), l.listener_arn]
|
79
|
+
}.sort
|
80
|
+
else
|
81
|
+
puts listeners.map(&:listener_arn)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
data/lib/awful/ecs.rb
CHANGED
@@ -171,6 +171,29 @@ module Awful
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
+
desc 'update', 'update a service'
|
175
|
+
method_option :desired_count, aliases: '-d', type: :numeric, default: nil, desc: 'desired number of tasks'
|
176
|
+
method_option :task_definition, aliases: '-t', type: :string, default: nil, desc: 'task def as family:revision'
|
177
|
+
def update(cluster, service)
|
178
|
+
params = {
|
179
|
+
cluster: cluster,
|
180
|
+
service: service,
|
181
|
+
desired_count: options[:desired_count],
|
182
|
+
task_definition: options[:task_definition],
|
183
|
+
}.reject { |k,v| v.nil? }
|
184
|
+
|
185
|
+
ecs.update_service(params).service.output do |response|
|
186
|
+
puts YAML.dump(stringify_keys(response.to_h))
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
desc 'events', 'list events for given CLUSTER and SERVICE'
|
191
|
+
def events(cluster, service)
|
192
|
+
ecs.describe_services(cluster: cluster, services: [service]).services.first.events.output do |events|
|
193
|
+
print_table events.map { |e| [e.created_at, e.id, e.message] }
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
174
197
|
desc 'run_task CLUSTER TASK_DEFINITION', 'run a task on given cluster'
|
175
198
|
method_option :command, aliases: '-c', default: nil, desc: 'override container command as name:cmd,arg1,arg2'
|
176
199
|
def run_task(cluster, task)
|
data/lib/awful/ssm.rb
CHANGED
@@ -26,7 +26,7 @@ module Awful
|
|
26
26
|
desc 'ls', 'list commands'
|
27
27
|
method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'Long listing'
|
28
28
|
def ls
|
29
|
-
ssm.list_commands.commands.
|
29
|
+
ssm.list_commands.commands.output do |cmds|
|
30
30
|
if options[:long]
|
31
31
|
print_table cmds.map { |c|
|
32
32
|
[
|
@@ -46,7 +46,7 @@ module Awful
|
|
46
46
|
|
47
47
|
desc 'dump ID', 'get details of command invocation for command ID'
|
48
48
|
def dump(id)
|
49
|
-
ssm.list_command_invocations(command_id: id, details: true).command_invocations.
|
49
|
+
ssm.list_command_invocations(command_id: id, details: true).command_invocations.output do |cmds|
|
50
50
|
cmds.each do |cmd|
|
51
51
|
puts YAML.dump(stringify_keys(cmd.to_hash))
|
52
52
|
end
|
@@ -60,7 +60,7 @@ module Awful
|
|
60
60
|
filter = [{key: 'PlatformTypes', value: options[:platform_types].capitalize}]
|
61
61
|
ssm.list_documents(document_filter_list: filter).document_identifiers.select do |doc|
|
62
62
|
doc.name.match(/#{name}/i)
|
63
|
-
end.
|
63
|
+
end.output do |docs|
|
64
64
|
if options[:long]
|
65
65
|
print_table docs.map { |d| [d.name, d.platform_types.join(',')] }
|
66
66
|
else
|
@@ -86,7 +86,7 @@ module Awful
|
|
86
86
|
parameters: {
|
87
87
|
commands: options[:commands]
|
88
88
|
}
|
89
|
-
).
|
89
|
+
).output do |response|
|
90
90
|
puts response.command.command_id
|
91
91
|
end
|
92
92
|
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.140
|
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-09-
|
11
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,6 +84,7 @@ description: AWS cmdline and yaml loader.
|
|
84
84
|
email:
|
85
85
|
- rlister+gh@gmail.com
|
86
86
|
executables:
|
87
|
+
- alb
|
87
88
|
- ami
|
88
89
|
- apigw
|
89
90
|
- asg
|
@@ -122,6 +123,7 @@ files:
|
|
122
123
|
- README.md
|
123
124
|
- Rakefile
|
124
125
|
- awful.gemspec
|
126
|
+
- bin/alb
|
125
127
|
- bin/ami
|
126
128
|
- bin/apigw
|
127
129
|
- bin/asg
|
@@ -152,6 +154,7 @@ files:
|
|
152
154
|
- bin/ta
|
153
155
|
- bin/vpc
|
154
156
|
- lib/awful.rb
|
157
|
+
- lib/awful/alb.rb
|
155
158
|
- lib/awful/ami.rb
|
156
159
|
- lib/awful/api_gateway.rb
|
157
160
|
- lib/awful/api_gateway_deployments.rb
|