awful 0.0.183 → 0.1.0.alpha.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c1ab2fc365e4aaccd052206843ef554704ffd86d
4
- data.tar.gz: b4afadc9463ef855311cdea9e3e03ce6ebb3ee7a
2
+ SHA256:
3
+ metadata.gz: a6d920e5f1bbc5756ffe4eb9bccfde37f6203454ff1e8ab6f2c9fc05a464eb4c
4
+ data.tar.gz: 39315ee5a3569c65a329828158a8f38611db2dac2e3f62d02e2d3610a8dcf12f
5
5
  SHA512:
6
- metadata.gz: f7fbe4141ddaf40a4482d9562e12fd542ac0cdd42e84093beccdbfa36fd0e9c49525566cfa030a5e561e6b94fbd674f68ba1c248e8cede2a262e870a6fb108f8
7
- data.tar.gz: 89db4d459b0846fa4d7b2b4b7e1075a9daf7f538833e14139cdf937eb3b0212d59bfbea0ce31b0fe47545658d5a4f3877096945c2c881bae47a8d2098404f9a3
6
+ metadata.gz: ce7775521074720421fe220028e0dad577aff399b0239585ced2126056dc469f3f64e431b90f9ffbb6cc012b3bfde40c37082879296d6530179db322ccc43a5f
7
+ data.tar.gz: 970509127de9063ec007ca57488c933158f7a4a08f4919d7540da5538da0d544e502c3a09d95e39d26a48c1500dbd4e65226bc2127b69fdb0a30358027c0d8be
data/awful.gemspec CHANGED
@@ -18,10 +18,20 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
23
 
24
- spec.add_dependency('aws-sdk', '~> 2')
25
24
  spec.add_dependency('thor')
26
25
  spec.add_dependency('dotenv')
27
- end
26
+
27
+ spec.add_dependency('aws-sdk-autoscaling')
28
+ spec.add_dependency('aws-sdk-cloudformation')
29
+ spec.add_dependency('aws-sdk-dynamodb')
30
+ spec.add_dependency('aws-sdk-ec2')
31
+ spec.add_dependency('aws-sdk-ecr')
32
+ spec.add_dependency('aws-sdk-elasticloadbalancingv2')
33
+ spec.add_dependency('aws-sdk-rds')
34
+ spec.add_dependency('aws-sdk-s3')
35
+ spec.add_dependency('aws-sdk-secretsmanager')
36
+ spec.add_dependency('aws-sdk-ssm')
37
+ end
data/bin/firehose ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ #-*- mode: ruby; -*-
3
+
4
+ require 'awful'
5
+ require 'awful/firehose'
6
+
7
+ Awful::Firehose.start(ARGV)
data/bin/kinesis ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ #-*- mode: ruby; -*-
3
+
4
+ require 'awful'
5
+ require 'awful/kinesis'
6
+
7
+ Awful::Kinesis.start(ARGV)
@@ -2,6 +2,6 @@
2
2
  #-*- mode: ruby; -*-
3
3
 
4
4
  require 'awful'
5
- require 'awful/param'
5
+ require 'awful/secret'
6
6
 
7
- Awful::Param.start(ARGV)
7
+ Awful::Secret.start(ARGV)
data/lib/awful/alb.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'aws-sdk-elasticloadbalancingv2'
2
+
1
3
  module Awful
2
4
  module Short
3
5
  def alb(*args)
@@ -17,10 +19,6 @@ module Awful
17
19
  }
18
20
 
19
21
  no_commands do
20
- def color(string)
21
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
22
- end
23
-
24
22
  def alb
25
23
  @alb ||= Aws::ElasticLoadBalancingV2::Client.new
26
24
  end
@@ -167,4 +165,4 @@ module Awful
167
165
  end
168
166
 
169
167
  end
170
- end
168
+ end
data/lib/awful/ami.rb CHANGED
@@ -28,10 +28,6 @@ module Awful
28
28
 
29
29
  ec2.describe_images(params).images
30
30
  end
31
-
32
- def color(string)
33
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
34
- end
35
31
  end
36
32
 
37
33
  desc 'ls [IDS]', 'list AMIs'
@@ -106,4 +102,4 @@ module Awful
106
102
  end
107
103
  end
108
104
  end
109
- end
105
+ end
@@ -1,3 +1,5 @@
1
+ require 'aws-sdk-autoscaling'
2
+
1
3
  module Awful
2
4
  module Short
3
5
  def asg(*args)
@@ -28,10 +30,6 @@ module Awful
28
30
  }
29
31
 
30
32
  no_commands do
31
- def color(string)
32
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
33
- end
34
-
35
33
  def all_matching_asgs(name)
36
34
  autoscaling.describe_auto_scaling_groups.map(&:auto_scaling_groups).flatten.select do |asg|
37
35
  asg.auto_scaling_group_name.match(name) or tag_name(asg, '').match(name)
@@ -416,4 +414,4 @@ module Awful
416
414
  autoscaling.exit_standby(auto_scaling_group_name: name, instance_ids: instance_ids)
417
415
  end
418
416
  end
419
- end
417
+ end
@@ -1,3 +1,5 @@
1
+ require 'aws-sdk-cloudformation'
2
+
1
3
  module Awful
2
4
  module Short
3
5
  def changesets(*args)
@@ -29,10 +31,6 @@ module Awful
29
31
  def cf
30
32
  @cf ||= Aws::CloudFormation::Client.new
31
33
  end
32
-
33
- def color(string)
34
- set_color(string, COLORS.fetch(string.downcase.to_sym, :blue))
35
- end
36
34
  end
37
35
 
38
36
  ## if no task given , run this
@@ -87,4 +85,4 @@ module Awful
87
85
  desc 'changesets', 'control changesets'
88
86
  subcommand 'changesets', Changesets
89
87
  end
90
- end
88
+ end
@@ -1,3 +1,5 @@
1
+ require 'aws-sdk-cloudformation'
2
+
1
3
  module Awful
2
4
  module Short
3
5
  def cf(*args)
@@ -8,30 +10,35 @@ module Awful
8
10
  class CloudFormation < Cli
9
11
 
10
12
  COLORS = {
11
- create_in_progress: :yellow,
12
- delete_in_progress: :yellow,
13
- update_in_progress: :yellow,
14
- update_complete_cleanup_in_progress: :yellow,
15
- create_failed: :red,
16
- delete_failed: :red,
17
- update_failed: :red,
18
- create_complete: :green,
19
- delete_complete: :green,
20
- update_complete: :green,
21
- delete_skipped: :yellow,
22
- rollback_in_progress: :red,
23
- rollback_complete: :red,
13
+ CREATE_IN_PROGRESS: :yellow,
14
+ DELETE_IN_PROGRESS: :yellow,
15
+ UPDATE_IN_PROGRESS: :yellow,
16
+ UPDATE_COMPLETE_CLEANUP_IN_PROGRESS: :yellow,
17
+ CREATE_FAILED: :red,
18
+ DELETE_FAILED: :red,
19
+ UPDATE_FAILED: :red,
20
+ CREATE_COMPLETE: :green,
21
+ DELETE_COMPLETE: :green,
22
+ UPDATE_COMPLETE: :green,
23
+ DELETE_SKIPPED: :yellow,
24
+ ROLLBACK_IN_PROGRESS: :red,
25
+ ROLLBACK_COMPLETE: :red,
26
+ ROLLBACK_FAILED: :red,
27
+ ACTIVE: :green,
28
+ DELETED: :red,
24
29
  }
25
30
 
26
- no_commands do
27
- def cf
28
- @cf ||= Aws::CloudFormation::Client.new
29
- end
30
-
31
- def color(string)
32
- set_color(string, COLORS.fetch(string.downcase.to_sym, :blue))
33
- end
31
+ ## stack statuses that are not DELETE_COMPLETE
32
+ STATUSES = %i[
33
+ CREATE_IN_PROGRESS CREATE_FAILED CREATE_COMPLETE
34
+ ROLLBACK_IN_PROGRESS ROLLBACK_FAILED ROLLBACK_COMPLETE
35
+ DELETE_IN_PROGRESS DELETE_FAILED
36
+ UPDATE_IN_PROGRESS UPDATE_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_COMPLETE
37
+ UPDATE_ROLLBACK_IN_PROGRESS UPDATE_ROLLBACK_FAILED UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_ROLLBACK_COMPLETE
38
+ REVIEW_IN_PROGRESS
39
+ ]
34
40
 
41
+ no_commands do
35
42
  ## get list of stacks
36
43
  def stack_summaries(next_token = nil)
37
44
  response = cf.list_stacks(next_token: next_token)
@@ -45,28 +52,16 @@ module Awful
45
52
  end
46
53
 
47
54
  desc 'ls [PATTERN]', 'list cloudformation stacks matching PATTERN'
48
- method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'Long listing'
49
- method_option :all, aliases: '-a', type: :boolean, default: false, desc: 'Show all, including stacks in DELETE_COMPLETE'
50
- def ls(name = /./)
51
- stacks = stack_summaries
52
-
53
- ## skip deleted stacks unless -a given
54
- unless options[:all]
55
- stacks = stacks.select { |stack| stack.stack_status != 'DELETE_COMPLETE' }
56
- end
57
-
58
- ## match on given arg
59
- stacks.select do |stack|
60
- stack.stack_name.match(name)
55
+ method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
56
+ def ls(name = nil)
57
+ paginate(:stack_summaries) do |next_token|
58
+ cf.list_stacks(stack_status_filter: STATUSES, next_token: next_token)
59
+ end.tap do |stacks|
60
+ stacks.select! { |s| s.stack_name.match(name) } if name
61
61
  end.output do |list|
62
62
  if options[:long]
63
63
  print_table list.map { |s|
64
- [
65
- s.stack_name,
66
- s.creation_time,
67
- color(s.stack_status),
68
- s.template_description,
69
- ]
64
+ [s.stack_name, s.creation_time, color(s.stack_status), s.template_description]
70
65
  }.sort
71
66
  else
72
67
  puts list.map(&:stack_name).sort
@@ -279,5 +274,23 @@ module Awful
279
274
  end
280
275
  puts cf.estimate_template_cost(template_body: template, parameters: parameters).url
281
276
  end
277
+
278
+ desc 'sets', 'list stack sets'
279
+ method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
280
+ method_option :status, aliases: '-s', type: :string, default: 'ACTIVE', desc: 'ACTIVE or DELETED'
281
+ def sets
282
+ paginate(:summaries) do |next_token|
283
+ cf.list_stack_sets(status: options[:status].upcase, next_token: next_token)
284
+ end.output do |sets|
285
+ if options[:long]
286
+ print_table sets.map { |s|
287
+ [s.stack_set_name, s.stack_set_id, color(s.status), s.description]
288
+ }
289
+ else
290
+ puts sets.map(&:stack_set_name)
291
+ end
292
+ end
293
+ end
294
+
282
295
  end
283
- end
296
+ end
@@ -18,10 +18,6 @@ module Awful
18
18
  def cloudfront
19
19
  @cloudfront ||= Aws::CloudFront::Client.new
20
20
  end
21
-
22
- def color(string)
23
- set_color(string, COLORS.fetch(string.downcase.to_sym, :blue))
24
- end
25
21
  end
26
22
 
27
23
  desc 'ls', 'list distributions'
@@ -101,4 +97,4 @@ module Awful
101
97
  end
102
98
  end
103
99
  end
104
- end
100
+ end
@@ -15,10 +15,6 @@ module Awful
15
15
  def events
16
16
  @events ||= Aws::CloudWatchEvents::Client.new
17
17
  end
18
-
19
- def color(string)
20
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
21
- end
22
18
  end
23
19
 
24
20
  desc 'ls [PREFIX]', 'list events'
@@ -77,4 +73,4 @@ module Awful
77
73
  end
78
74
 
79
75
  end
80
- end
76
+ end
data/lib/awful/config.rb CHANGED
@@ -21,10 +21,6 @@ module Awful
21
21
  def config
22
22
  @_config ||= Aws::ConfigService::Client.new
23
23
  end
24
-
25
- def color(string)
26
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
27
- end
28
24
  end
29
25
 
30
26
  desc 'recorders', 'show delivery recorders'
@@ -85,4 +81,4 @@ module Awful
85
81
  end
86
82
 
87
83
  end
88
- end
84
+ end
@@ -1,3 +1,4 @@
1
+ require 'aws-sdk-dynamodb'
1
2
  require 'json'
2
3
  require 'awful/dynamodb_streams'
3
4
 
@@ -17,10 +18,6 @@ module Awful
17
18
  }
18
19
 
19
20
  no_commands do
20
- def color(string)
21
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
22
- end
23
-
24
21
  ## return array of tables names matching name
25
22
  def all_matching_tables(name)
26
23
  tables = []
@@ -428,4 +425,4 @@ module Awful
428
425
  desc 'streams SUBCOMMANDS', 'subcommands for dynamodb streams'
429
426
  subcommand 'streams', Streams
430
427
  end
431
- end
428
+ end
data/lib/awful/ec2.rb CHANGED
@@ -1,26 +1,13 @@
1
1
  require 'base64'
2
2
 
3
3
  module Awful
4
- module Short
5
- def ec2(*args)
6
- Awful::Ec2.new.invoke(*args)
7
- end
8
- end
9
-
10
4
  class Ec2 < Cli
11
-
12
5
  COLORS = {
13
6
  running: :green,
14
7
  stopped: :yellow,
15
8
  terminated: :red,
16
9
  }
17
10
 
18
- no_commands do
19
- def color(string)
20
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
21
- end
22
- end
23
-
24
11
  desc 'ls [NAME]', 'get instances with given name regex'
25
12
  method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'Long listing'
26
13
  method_option :ids, aliases: '-i', type: :array, default: [], desc: 'List of instance ids to retrieve'
data/lib/awful/ecr.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'aws-sdk-ecr'
1
2
  require 'json'
2
3
  require 'base64'
3
4
 
@@ -191,4 +192,4 @@ module Awful
191
192
  puts "deleted: #{deleted}, failures: #{failures}"
192
193
  end
193
194
  end
194
- end
195
+ end
data/lib/awful/ecs.rb CHANGED
@@ -21,10 +21,6 @@ module Awful
21
21
  def ecs
22
22
  @ecs ||= Aws::ECS::Client.new
23
23
  end
24
-
25
- def color(string)
26
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
27
- end
28
24
  end
29
25
 
30
26
  desc 'ls NAME', 'list ECS clusters'
@@ -253,4 +249,4 @@ module Awful
253
249
  end
254
250
  end
255
251
  end
256
- end
252
+ end
@@ -17,10 +17,6 @@ module Awful
17
17
  def elasticache
18
18
  @elasticache ||= Aws::ElastiCache::Client.new
19
19
  end
20
-
21
- def color(string)
22
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
23
- end
24
20
  end
25
21
 
26
22
  desc 'ls [ID]', 'list clusters'
@@ -71,4 +67,4 @@ module Awful
71
67
  end
72
68
  end
73
69
  end
74
- end
70
+ end
data/lib/awful/elb.rb CHANGED
@@ -12,10 +12,6 @@ module Awful
12
12
  }
13
13
 
14
14
  no_commands do
15
- def color(string)
16
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
17
- end
18
-
19
15
  ## cannot search ELBs by tag, so just name here
20
16
  def all_matching_elbs(name)
21
17
  elb.describe_load_balancers.map(&:load_balancer_descriptions).flatten.select do |elb|
@@ -158,4 +154,4 @@ module Awful
158
154
  end
159
155
  end
160
156
  end
161
- end
157
+ end
data/lib/awful/emr.rb CHANGED
@@ -17,10 +17,6 @@ module Awful
17
17
  def emr
18
18
  @emr ||= Aws::EMR::Client.new
19
19
  end
20
-
21
- def color(string)
22
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
23
- end
24
20
  end
25
21
 
26
22
  desc 'ls', 'list clusters'
@@ -61,4 +57,4 @@ module Awful
61
57
  end
62
58
 
63
59
  end
64
- end
60
+ end
@@ -0,0 +1,63 @@
1
+ require 'yaml'
2
+
3
+ module Awful
4
+ module Short
5
+ def firehose(*args)
6
+ Awful::Firehose.new.invoke(*args)
7
+ end
8
+ end
9
+
10
+ class Firehose < Cli
11
+ COLORS = {
12
+ ACTIVE: :green,
13
+ DELETING: :red,
14
+ }
15
+
16
+ no_commands do
17
+ def firehose
18
+ @_firehose ||= Aws::Firehose::Client.new
19
+ end
20
+
21
+ ## special-case paginator for delivery streams
22
+ def paginate_delivery_streams(thing)
23
+ token = nil
24
+ things = []
25
+ loop do
26
+ resp = yield(token)
27
+ items = resp.send(thing)
28
+ things += items
29
+ token = items.last
30
+ break unless resp.has_more_delivery_streams
31
+ end
32
+ things
33
+ end
34
+ end
35
+
36
+ desc 'ls', 'list firehose streams'
37
+ method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
38
+ def ls
39
+ paginate_delivery_streams(:delivery_stream_names) do |start|
40
+ firehose.list_delivery_streams(exclusive_start_delivery_stream_name: start)
41
+ end.output do |streams|
42
+ if options[:long]
43
+ print_table streams.map { |name|
44
+
45
+ s = firehose.describe_delivery_stream(delivery_stream_name: name).delivery_stream_description
46
+ op = s.has_more_destinations ? '>' : ''
47
+ [s.delivery_stream_name, op + s.destinations.count.to_s, color(s.delivery_stream_status), s.delivery_stream_type, 'v' + s.version_id.to_s, s.create_timestamp]
48
+ }
49
+ else
50
+ puts streams
51
+ end
52
+ end
53
+ end
54
+
55
+ desc 'dump NAME', 'describe firehose stream'
56
+ def dump(name)
57
+ firehose.describe_delivery_stream(delivery_stream_name: name).delivery_stream_description.output do |stream|
58
+ puts YAML.dump(stringify_keys(stream.to_hash))
59
+ end
60
+ end
61
+
62
+ end
63
+ end
data/lib/awful/iam.rb CHANGED
@@ -11,10 +11,6 @@ module Awful
11
11
  def iam
12
12
  @iam ||= Aws::IAM::Client.new
13
13
  end
14
-
15
- def color(string)
16
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
17
- end
18
14
  end
19
15
 
20
16
  desc 'users', 'list users'
@@ -159,4 +155,4 @@ module Awful
159
155
 
160
156
  end
161
157
 
162
- end
158
+ end
@@ -0,0 +1,62 @@
1
+ require 'yaml'
2
+
3
+ module Awful
4
+ module Short
5
+ def kinesis(*args)
6
+ Awful::Kinesis.new.invoke(*args)
7
+ end
8
+ end
9
+
10
+ class Kinesis < Cli
11
+ COLORS = {
12
+ ACTIVE: :green,
13
+ DELETING: :red,
14
+ }
15
+
16
+ no_commands do
17
+ def kinesis
18
+ @_kinesis ||= Aws::Kinesis::Client.new
19
+ end
20
+
21
+ ## special-case paginator for streams
22
+ def paginate_streams(thing)
23
+ token = nil
24
+ things = []
25
+ loop do
26
+ resp = yield(token)
27
+ items = resp.send(thing)
28
+ things += items
29
+ token = items.last
30
+ break unless resp.has_more_streams
31
+ end
32
+ things
33
+ end
34
+ end
35
+
36
+ desc 'ls', 'list streams'
37
+ method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
38
+ def ls
39
+ paginate_streams(:stream_names) do |start|
40
+ kinesis.list_streams(exclusive_start_stream_name: start)
41
+ end.output do |streams|
42
+ if options[:long]
43
+ print_table streams.map { |name|
44
+ s = kinesis.describe_stream(stream_name: name).stream_description
45
+ op = s.has_more_shards ? '>' : ''
46
+ [s.stream_name, op + s.shards.count.to_s, color(s.stream_status), s.encryption_type, s.retention_period_hours.to_s + 'h', s.stream_creation_timestamp]
47
+ }
48
+ else
49
+ puts streams
50
+ end
51
+ end
52
+ end
53
+
54
+ desc 'dump [NAME]', 'describe a stream by name'
55
+ def dump(name)
56
+ kinesis.describe_stream(stream_name: name).stream_description.output do |stream|
57
+ puts YAML.dump(stringify_keys(stream.to_hash))
58
+ end
59
+ end
60
+
61
+ end
62
+ end
data/lib/awful/kms.rb CHANGED
@@ -18,10 +18,6 @@ module Awful
18
18
  @_kms ||= Aws::KMS::Client.new
19
19
  end
20
20
 
21
- def color(string)
22
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
23
- end
24
-
25
21
  def list_aliases
26
22
  paginate(:aliases) do |marker|
27
23
  kms.list_aliases(marker: marker)
@@ -135,4 +131,4 @@ module Awful
135
131
  end
136
132
 
137
133
  end
138
- end
134
+ end
@@ -13,12 +13,6 @@ module Awful
13
13
  Disabled: :red
14
14
  }
15
15
 
16
- no_commands do
17
- def color(string)
18
- set_color(string, COLORS.fetch(string.to_sym, :yellow))
19
- end
20
- end
21
-
22
16
  desc 'ls [FUNCTION_NAME]', 'list event source mappings'
23
17
  method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'Long listing'
24
18
  def ls(name = nil)
@@ -67,4 +61,4 @@ module Awful
67
61
  end
68
62
  end
69
63
  end
70
- end
64
+ end
data/lib/awful/rds.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'aws-sdk-rds'
2
+
1
3
  module Awful
2
4
 
3
5
  class Rds < Cli