dyna 0.2.0 → 0.2.3
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/README.md +6 -0
- data/bin/dyna +1 -0
- data/dyna.gemspec +1 -1
- data/lib/dyna/dsl/table.rb +11 -0
- data/lib/dyna/exporter.rb +2 -0
- data/lib/dyna/version.rb +1 -1
- data/lib/dyna/wrapper/dynamo_db_wrapper.rb +1 -0
- data/lib/dyna/wrapper/table.rb +51 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2520a55eb00141922591e6267ab65b2b970e4f8d9fa0467aa036df4256906d7
|
4
|
+
data.tar.gz: c5ec98a3593ef45628fec2f16b7a5a7fe409d1ed1b46264ece28ee05482df9ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed0a5b3f61a5b1c059799c106fa15e0ff7e921cc7904590745ac97157a6c824fe696736085f82600eb2df9d1a7644d2005ac978453bc143387365891eba7b22c
|
7
|
+
data.tar.gz: 7709061ccca28977623adbfa5c0e44838103360e2abd0ea3fc7c6b700f4505cb8d7f93fcf2dff6a17ddb3fd1e32f632bb1c4f7e34fd5afc0e626e264b409c730
|
data/README.md
CHANGED
@@ -41,6 +41,7 @@ Usage: dyna [options]
|
|
41
41
|
-k, --access-key ACCESS_KEY
|
42
42
|
-s, --secret-key SECRET_KEY
|
43
43
|
-r, --region REGION
|
44
|
+
--endpoint DYNAMO_ENDPOINT
|
44
45
|
-a, --apply
|
45
46
|
-f, --file FILE
|
46
47
|
-n, --table_names TABLE_LIST
|
@@ -74,6 +75,11 @@ dynamo_db "ap-northeast-1" do
|
|
74
75
|
attribute_type: "S",
|
75
76
|
)
|
76
77
|
|
78
|
+
time_to_live_specification(
|
79
|
+
enabled: true,
|
80
|
+
attribute_name: "ttl",
|
81
|
+
)
|
82
|
+
|
77
83
|
provisioned_throughput(
|
78
84
|
read_capacity_units: 1,
|
79
85
|
write_capacity_units: 2,
|
data/bin/dyna
CHANGED
@@ -45,6 +45,7 @@ ARGV.options do |opt|
|
|
45
45
|
opt.on('-s', '--secret-key SECRET_KEY') {|v| secret_key = v }
|
46
46
|
opt.on('-r', '--region REGION') {|v| region = v }
|
47
47
|
opt.on('-l', '--use-local') { options[:use_local] = true }
|
48
|
+
opt.on('', '--endpoint DYNAMO_ENDPOINT') {|v| options[:dynamo_endpoint] = v }
|
48
49
|
opt.on('-a', '--apply') { mode = :apply }
|
49
50
|
opt.on('-f', '--file FILE') {|v| file = v }
|
50
51
|
opt.on('', '--table_names TABLE_NAMES', Array) {|v| options[:table_names] = v }
|
data/dyna.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency 'hashie', '~> 3.4'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
30
|
-
spec.add_development_dependency 'rake', '
|
30
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
31
31
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
32
|
spec.add_development_dependency 'pry-byebug', '~> 3.4'
|
33
33
|
end
|
data/lib/dyna/dsl/table.rb
CHANGED
@@ -13,6 +13,10 @@ module Dyna
|
|
13
13
|
:table_name => table_name,
|
14
14
|
:scalable_targets => [],
|
15
15
|
:scaling_policies => [],
|
16
|
+
:time_to_live_specification => {
|
17
|
+
enabled: false,
|
18
|
+
attribute_name: nil,
|
19
|
+
}
|
16
20
|
})
|
17
21
|
instance_eval(&block)
|
18
22
|
end
|
@@ -100,6 +104,13 @@ module Dyna
|
|
100
104
|
}
|
101
105
|
end
|
102
106
|
|
107
|
+
def time_to_live_specification(enabled:, attribute_name:)
|
108
|
+
@result.time_to_live_specification = {
|
109
|
+
enabled: enabled,
|
110
|
+
attribute_name: attribute_name,
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
103
114
|
class LocalSecondaryIndex
|
104
115
|
attr_accessor :result
|
105
116
|
|
data/lib/dyna/exporter.rb
CHANGED
@@ -119,6 +119,7 @@ module Dyna
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def self.scalable_targets_by_resource_id
|
122
|
+
return {} unless @aas
|
122
123
|
return @scalable_targets_by_resource_id if @scalable_targets_by_resource_id
|
123
124
|
|
124
125
|
results = []
|
@@ -138,6 +139,7 @@ module Dyna
|
|
138
139
|
end
|
139
140
|
|
140
141
|
def self.scaling_policies_by_resource_id
|
142
|
+
return {} unless @aas
|
141
143
|
return @scaling_policies_by_resource_id if @scaling_policies_by_resource_id
|
142
144
|
|
143
145
|
results = []
|
data/lib/dyna/version.rb
CHANGED
data/lib/dyna/wrapper/table.rb
CHANGED
@@ -31,6 +31,9 @@ module Dyna
|
|
31
31
|
wait_until_table_is_active
|
32
32
|
update_stream_specification(dsl_stream_specification(dsl))
|
33
33
|
end
|
34
|
+
unless time_to_live_eql?(dsl)
|
35
|
+
update_time_to_live(dsl)
|
36
|
+
end
|
34
37
|
unless auto_scaling_eql?(dsl)
|
35
38
|
update_auto_scaling(dsl)
|
36
39
|
end
|
@@ -65,6 +68,23 @@ module Dyna
|
|
65
68
|
end
|
66
69
|
|
67
70
|
private
|
71
|
+
|
72
|
+
def aws_time_to_live
|
73
|
+
@ttl ||= @ddb.describe_time_to_live(table_name: @table.table_name).time_to_live_description
|
74
|
+
end
|
75
|
+
|
76
|
+
def time_to_live_eql?(dsl)
|
77
|
+
wait_until_table_is_active
|
78
|
+
ttl = aws_time_to_live
|
79
|
+
unless %w/ENABLED DISABLED/.include?(ttl.time_to_live_status)
|
80
|
+
raise "time to live status is #{ttl.time_to_live_status} and must be ENABLED or DISABLED to apply"
|
81
|
+
end
|
82
|
+
same_status = dsl.time_to_live_specification.enabled.to_s == 'false' && ttl.time_to_live_status == 'DISABLED' || dsl.time_to_live_specification.enabled.to_s == 'true' && ttl.time_to_live_status == 'ENABLED'
|
83
|
+
same_name = dsl.time_to_live_specification.attribute_name.to_s == ttl.attribute_name.to_s
|
84
|
+
|
85
|
+
same_status && same_name
|
86
|
+
end
|
87
|
+
|
68
88
|
def auto_scaling_eql?(dsl)
|
69
89
|
scalable_targets_eql?(dsl) && scaling_policies_eql?(dsl)
|
70
90
|
end
|
@@ -218,7 +238,7 @@ module Dyna
|
|
218
238
|
df_params[:billing_mode] = definition[:billing_mode]
|
219
239
|
end
|
220
240
|
|
221
|
-
if provisioned_throughput_eql?(dsl) == false && dsl[:scalable_targets].empty?
|
241
|
+
if dsl[:provisioned_throughput] && provisioned_throughput_eql?(dsl) == false && dsl[:scalable_targets].empty?
|
222
242
|
params[:provisioned_throughput] = dsl[:provisioned_throughput].symbolize_keys
|
223
243
|
df_params[:provisioned_throughput] = self_provisioned_throughput[:provisioned_throughput]
|
224
244
|
end
|
@@ -262,6 +282,11 @@ module Dyna
|
|
262
282
|
end
|
263
283
|
|
264
284
|
def update_auto_scaling(dsl)
|
285
|
+
unless @options.aas
|
286
|
+
log(:warn, "auto scalings can not be used in local mode.".yellow, false)
|
287
|
+
return
|
288
|
+
end
|
289
|
+
|
265
290
|
has_change = false
|
266
291
|
unless scalable_targets_eql?(dsl)
|
267
292
|
has_change = true
|
@@ -302,6 +327,31 @@ module Dyna
|
|
302
327
|
@options.updated = true
|
303
328
|
end
|
304
329
|
end
|
330
|
+
|
331
|
+
def update_time_to_live(dsl)
|
332
|
+
params = { table_name: @table.table_name }
|
333
|
+
if dsl.time_to_live_specification.enabled.to_s == 'true'
|
334
|
+
params[:time_to_live_specification] = {
|
335
|
+
enabled: dsl.time_to_live_specification.enabled,
|
336
|
+
attribute_name: dsl.time_to_live_specification.attribute_name,
|
337
|
+
}
|
338
|
+
else
|
339
|
+
params[:time_to_live_specification] = {
|
340
|
+
enabled: false,
|
341
|
+
attribute_name: aws_time_to_live.attribute_name,
|
342
|
+
}
|
343
|
+
end
|
344
|
+
|
345
|
+
log(:info, " table: #{@table.table_name}(update time to live)".green, false)
|
346
|
+
log(:info, " => enabled: #{params[:time_to_live_specification][:enabled]}".cyan, false)
|
347
|
+
log(:info, " => attribute_name: #{params[:time_to_live_specification][:attribute_name]}".cyan, false)
|
348
|
+
|
349
|
+
unless @options.dry_run
|
350
|
+
log(:debug, params, false)
|
351
|
+
@ddb.update_time_to_live(params)
|
352
|
+
@options.updated = true
|
353
|
+
end
|
354
|
+
end
|
305
355
|
end
|
306
356
|
end
|
307
357
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dyna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-dynamodb
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 12.3.3
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 12.3.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,8 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '0'
|
189
189
|
requirements: []
|
190
|
-
|
191
|
-
rubygems_version: 2.7.6
|
190
|
+
rubygems_version: 3.1.2
|
192
191
|
signing_key:
|
193
192
|
specification_version: 4
|
194
193
|
summary: Codenize DynamoDB table
|