awful 0.0.82 → 0.0.83
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/dyn +2 -1
- data/bin/lambda +2 -1
- data/lib/awful.rb +5 -5
- data/lib/awful/dynamodb.rb +6 -6
- data/lib/awful/dynamodb_streams.rb +21 -23
- data/lib/awful/lambda.rb +4 -26
- data/lib/awful/lambda_events.rb +64 -0
- data/lib/awful/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c30ff309aad62cd97f07ddb4d9f33a3264a1d942
|
4
|
+
data.tar.gz: 07c215651cd3249b9309b3174c3c5b5bc19f8507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dcea4755931848808158251e79fa012a3ff660d4e8fd1bfb883739d569003ff3b096559a4143835a69865a2a119a49521121ff52a6130a532d208da67711a71
|
7
|
+
data.tar.gz: 22f850070078679aee2a7b0e028efb163f724a7c6a8d17bef825ae36c6f3254bc3cca904f0e23e4bd135f0703ca223fe75ad755443edf5ee8c756c8b094f7d7a
|
data/bin/dyn
CHANGED
data/bin/lambda
CHANGED
data/lib/awful.rb
CHANGED
@@ -57,14 +57,14 @@ module Awful
|
|
57
57
|
@dynamodb_simple ||= Aws::DynamoDB::Client.new(options)
|
58
58
|
end
|
59
59
|
|
60
|
-
def dynamodb_streams
|
61
|
-
@dynamodb_streams ||= Aws::DynamoDBStreams::Client.new
|
62
|
-
end
|
63
|
-
|
64
60
|
def s3
|
65
61
|
@s3 ||= Aws::S3::Client.new
|
66
62
|
end
|
67
63
|
|
64
|
+
def lambda
|
65
|
+
@lambda ||= Aws::Lambda::Client.new
|
66
|
+
end
|
67
|
+
|
68
68
|
def support
|
69
69
|
@support ||= Aws::Support::Client.new
|
70
70
|
end
|
@@ -157,4 +157,4 @@ module Awful
|
|
157
157
|
|
158
158
|
end
|
159
159
|
end
|
160
|
-
end
|
160
|
+
end
|
data/lib/awful/dynamodb.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module Awful
|
2
|
-
|
3
2
|
class DynamoDB < Cli
|
4
|
-
|
5
3
|
COLORS = {
|
6
4
|
CREATING: :yellow,
|
7
5
|
UPDATING: :yellow,
|
@@ -90,10 +88,10 @@ module Awful
|
|
90
88
|
end
|
91
89
|
end
|
92
90
|
|
93
|
-
desc '
|
91
|
+
desc 'enable_streams NAME', 'enable/disable streams on the table'
|
94
92
|
method_option :stream_view_type, aliases: '-t', default: 'NEW_IMAGE', desc: 'view type for the stream (NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES, KEYS_ONLY)'
|
95
93
|
method_option :disable, aliases: '-d', default: false, desc: 'disable the stream'
|
96
|
-
def
|
94
|
+
def enable_streams(name)
|
97
95
|
stream_specification = {stream_enabled: !options[:disable]}
|
98
96
|
stream_specification.merge!(stream_view_type: options[:stream_view_type].upcase) unless options[:disable]
|
99
97
|
dynamodb.update_table(table_name: name, stream_specification: stream_specification)
|
@@ -237,6 +235,8 @@ module Awful
|
|
237
235
|
p r
|
238
236
|
end
|
239
237
|
|
238
|
+
## see lambda_events.rb for subcommands
|
239
|
+
desc 'streams', 'subcommands for dynamodb streams'
|
240
|
+
subcommand 'streams', DynamodbStreams
|
240
241
|
end
|
241
|
-
|
242
|
-
end
|
242
|
+
end
|
@@ -1,56 +1,54 @@
|
|
1
1
|
module Awful
|
2
|
+
class DynamodbStreams < Cli
|
3
|
+
no_commands do
|
4
|
+
def streams
|
5
|
+
@streams ||= Aws::DynamoDBStreams::Client.new
|
6
|
+
end
|
7
|
+
end
|
2
8
|
|
3
|
-
|
4
|
-
|
5
|
-
desc 'ls [PATTERN]', 'list dynamodb streams [matching PATTERN]'
|
9
|
+
desc 'ls [NAME]', 'list dynamodb streams [for table NAME]'
|
6
10
|
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
7
11
|
def ls(table_name = nil, exclusive_start_stream_arn = nil)
|
8
|
-
|
12
|
+
response = streams.list_streams(
|
9
13
|
table_name: table_name,
|
10
14
|
exclusive_start_stream_arn: exclusive_start_stream_arn
|
11
|
-
|
15
|
+
)
|
12
16
|
|
13
|
-
|
17
|
+
streams = response.streams
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
19
|
+
## output
|
20
|
+
if options[:long]
|
21
|
+
print_table streams.map{ |s| [s.table_name, s.stream_arn] }.sort
|
22
|
+
else
|
23
|
+
puts streams.map(&:stream_arn)
|
21
24
|
end
|
22
25
|
|
23
26
|
## recurse if there is more data to fetch
|
24
|
-
if
|
25
|
-
streams += ls(table_name, r.last_evaluated_stream_arn)
|
26
|
-
end
|
27
|
-
|
27
|
+
streams += ls(table_name, response.last_evaluated_stream_arn) if response.last_evaluated_stream_arn
|
28
28
|
streams
|
29
29
|
end
|
30
30
|
|
31
31
|
desc 'dump ARN', 'describe the stream with ARN as yaml'
|
32
32
|
def dump(arn)
|
33
|
-
|
33
|
+
streams.describe_stream(stream_arn: arn).stream_description.tap do |stream|
|
34
34
|
puts YAML.dump(stringify_keys(stream.to_hash))
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
desc 'shards ARN', 'list shards for stream with ARN'
|
39
39
|
def shards(arn)
|
40
|
-
|
40
|
+
streams.describe_stream(stream_arn: arn).stream_description.shards.tap do |shards|
|
41
41
|
puts shards.map(&:shard_id)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
desc 'get_records ARN SHARD_ID', 'get records for given stream and shard'
|
46
46
|
def get_records(arn, shard_id)
|
47
|
-
iterator =
|
47
|
+
iterator = streams.get_shard_iterator(stream_arn: arn, shard_id: shard_id, shard_iterator_type: 'TRIM_HORIZON').shard_iterator
|
48
48
|
|
49
|
-
|
49
|
+
streams.get_records(shard_iterator: iterator).records.tap do |records|
|
50
50
|
print_table records.map { |r| [r.event_id, r.event_name, r.dynamodb.sequence_number, r.dynamodb.size_bytes] }
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
54
53
|
end
|
55
|
-
|
56
|
-
end
|
54
|
+
end
|
data/lib/awful/lambda.rb
CHANGED
@@ -2,14 +2,9 @@ require 'open-uri'
|
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
4
|
module Awful
|
5
|
-
|
6
5
|
class Lambda < Cli
|
7
6
|
|
8
7
|
no_commands do
|
9
|
-
def lambda
|
10
|
-
@lambda ||= Aws::Lambda::Client.new
|
11
|
-
end
|
12
|
-
|
13
8
|
## return zip file contents, make it if necessary
|
14
9
|
def zip_thing(thing)
|
15
10
|
if File.directory?(thing)
|
@@ -112,25 +107,8 @@ module Awful
|
|
112
107
|
end
|
113
108
|
end
|
114
109
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
def events(name)
|
119
|
-
if options[:create]
|
120
|
-
lambda.create_event_source_mapping(function_name: name, event_source_arn: options[:create], starting_position: 'LATEST').tap do |response|
|
121
|
-
puts YAML.dump(stringify_keys(response.to_hash))
|
122
|
-
end
|
123
|
-
else # list
|
124
|
-
lambda.list_event_source_mappings(function_name: name).event_source_mappings.tap do |sources|
|
125
|
-
if options[:long]
|
126
|
-
print_table sources.map { |s| [s.event_source_arn, s.state, "Batch size: #{s.batch_size}, Last result: #{s.last_processing_result}", s.last_modified] }
|
127
|
-
else
|
128
|
-
puts sources.map(&:event_source_arn)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
110
|
+
## see lambda_events.rb for subcommands
|
111
|
+
desc 'events', 'subcommands for lambda event mappings'
|
112
|
+
subcommand 'events', LambdaEvents
|
134
113
|
end
|
135
|
-
|
136
|
-
end
|
114
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Awful
|
2
|
+
class LambdaEvents < Cli
|
3
|
+
COLORS = {
|
4
|
+
OK: :green,
|
5
|
+
PROBLEM: :red,
|
6
|
+
Enabled: :green,
|
7
|
+
Disabled: :red
|
8
|
+
}
|
9
|
+
|
10
|
+
no_commands do
|
11
|
+
def color(string)
|
12
|
+
set_color(string, COLORS.fetch(string.to_sym, :yellow))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'ls [FUNCTION_NAME]', 'list event source mappings'
|
17
|
+
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
18
|
+
def ls(name = nil)
|
19
|
+
lambda.list_event_source_mappings(function_name: name).event_source_mappings.tap do |sources|
|
20
|
+
if options[:long]
|
21
|
+
print_table sources.map { |s|
|
22
|
+
[
|
23
|
+
s.uuid,
|
24
|
+
color(s.state),
|
25
|
+
"Batch size: #{s.batch_size}",
|
26
|
+
"Last result: #{color(s.last_processing_result.scan(/\w+/).first)}",
|
27
|
+
s.last_modified
|
28
|
+
]
|
29
|
+
}
|
30
|
+
else
|
31
|
+
puts sources.map(&:uuid)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'dump UUID', 'get config details for given mapping'
|
37
|
+
def dump(uuid)
|
38
|
+
lambda.get_event_source_mapping(uuid: uuid).tap do |details|
|
39
|
+
puts YAML.dump(stringify_keys(details.to_hash))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'create FUNCTION_NAME EVENT_SOURCE_ARN', 'identify a stream as an event source for a lambda function'
|
44
|
+
method_option :enabled, type: :boolean, default: true, desc: 'Lambda should begin polling the event source'
|
45
|
+
method_option :batch_size, type: :numeric, default: 1, desc: 'The largest number of records that lambda will retrieve'
|
46
|
+
method_option :starting_position, type: :string, default: 'TRIM_HORIZON', desc: 'Posn to start reading: TRIM_HORIZON, LATEST'
|
47
|
+
def create(name, src)
|
48
|
+
lambda.create_event_source_mapping(
|
49
|
+
function_name: name,
|
50
|
+
event_source_arn: src,
|
51
|
+
enabled: options[:enabled],
|
52
|
+
batch_size: options[:batch_size],
|
53
|
+
starting_position: options[:starting_position]
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
desc 'delete UUID', 'delete event source mapping with given id'
|
58
|
+
def delete(uuid)
|
59
|
+
if yes?("Really delete event source mapping #{uuid}?")
|
60
|
+
lambda.delete_event_source_mapping(uuid: uuid)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
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.83
|
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-01-
|
11
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- lib/awful/elb.rb
|
154
154
|
- lib/awful/iam.rb
|
155
155
|
- lib/awful/lambda.rb
|
156
|
+
- lib/awful/lambda_events.rb
|
156
157
|
- lib/awful/launch_config.rb
|
157
158
|
- lib/awful/rds.rb
|
158
159
|
- lib/awful/route53.rb
|