dynamocli 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36b53c1ee892def9c34a5ad8b7c73c24b152a1695924f3be978822653e3eaed3
4
- data.tar.gz: 847ea3ae63cb8fd46092bba1fde2cbda1ca605236dbb6867f73ed93bca5e474a
3
+ metadata.gz: cf0b1bae3beebc279a5eaabd92a509ed1b814c2127d69b1b7fa97773406b09dd
4
+ data.tar.gz: 99cf915195d3465fafca5be50bd99657b750cfb8feda6a83dc64b663a8710f19
5
5
  SHA512:
6
- metadata.gz: e153aa55521d0d7669cfa63194c01ed2cf096f5a8a4cf195bfa1258c41cc17c174df96dfb9ceba1d96e44dc4551684daa9378e8bf0c3bfdf1c4289ee6302453f
7
- data.tar.gz: efadb7ee0651538f7a99c533bf7743fa52ffee15068760853af7427e035dc4396bb2823e7bb1125ab9f897b1b417e7df7cbd3b5e8d4d358a2b534e8610388df9
6
+ metadata.gz: 693f43bdd1424c8ad114830cef71b3871db841f7bf3ae5a1d143d1fe70ff82d35105f9ada9482e4607ac85cb53fb960c8ffe81b61ef37f585f35d1fd9c22af93
7
+ data.tar.gz: 63957579490f76bb7444b005a5b75686662cd26c27b432c671be1f20eb5726f78c53accaf7dbf302b8f486f96ee99ccdac4ff5ca8767716d79767303db396f10
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.1.4] - 2019-07-29
6
+ ### Fixed
7
+ - Fix erase table with indexes.
8
+
9
+ ### Changed
10
+ - Add some life to logs.
11
+
5
12
  ## [0.1.3] - 2019-06-20
6
13
  ### Fixed
7
14
  - Specify the version of the cloudformation gem.
@@ -16,6 +23,7 @@ All notable changes to this project will be documented in this file.
16
23
  ### Added
17
24
  - Command to import data from a CSV file to a DynamoDB table.
18
25
 
26
+ [0.1.4]: https://github.com/matheussilvasantos/dynamocli/compare/v0.1.3...v0.1.4
19
27
  [0.1.3]: https://github.com/matheussilvasantos/dynamocli/compare/v0.1.2...v0.1.3
20
28
  [0.1.2]: https://github.com/matheussilvasantos/dynamocli/commit/6fd76a06819ff32464eeeae1f097bccd33f21387
21
29
  [0.1.0]: https://github.com/matheussilvasantos/dynamocli/releases/tag/v0.1.0
data/Gemfile.lock CHANGED
@@ -1,31 +1,37 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamocli (0.1.3)
4
+ dynamocli (0.1.4)
5
5
  aws-sdk-cloudformation (~> 1.23)
6
6
  aws-sdk-dynamodb (~> 1.28)
7
7
  thor (~> 0.20)
8
+ tty-logger (~> 0.1.0)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
13
  aws-eventstream (1.0.3)
13
- aws-partitions (1.177.0)
14
- aws-sdk-cloudformation (1.23.0)
15
- aws-sdk-core (~> 3, >= 3.56.0)
14
+ aws-partitions (1.193.0)
15
+ aws-sdk-cloudformation (1.25.0)
16
+ aws-sdk-core (~> 3, >= 3.61.1)
16
17
  aws-sigv4 (~> 1.1)
17
- aws-sdk-core (3.56.0)
18
+ aws-sdk-core (3.61.1)
18
19
  aws-eventstream (~> 1.0, >= 1.0.2)
19
20
  aws-partitions (~> 1.0)
20
21
  aws-sigv4 (~> 1.1)
21
22
  jmespath (~> 1.0)
22
- aws-sdk-dynamodb (1.31.0)
23
- aws-sdk-core (~> 3, >= 3.56.0)
23
+ aws-sdk-dynamodb (1.34.0)
24
+ aws-sdk-core (~> 3, >= 3.61.1)
24
25
  aws-sigv4 (~> 1.1)
25
26
  aws-sigv4 (1.1.0)
26
27
  aws-eventstream (~> 1.0, >= 1.0.2)
28
+ byebug (11.0.1)
27
29
  diff-lcs (1.3)
30
+ equatable (0.6.1)
28
31
  jmespath (1.4.0)
32
+ pastel (0.7.3)
33
+ equatable (~> 0.6)
34
+ tty-color (~> 0.5)
29
35
  rake (10.5.0)
30
36
  rspec (3.8.0)
31
37
  rspec-core (~> 3.8.0)
@@ -41,12 +47,16 @@ GEM
41
47
  rspec-support (~> 3.8.0)
42
48
  rspec-support (3.8.0)
43
49
  thor (0.20.3)
50
+ tty-color (0.5.0)
51
+ tty-logger (0.1.0)
52
+ pastel (~> 0.7.0)
44
53
 
45
54
  PLATFORMS
46
55
  ruby
47
56
 
48
57
  DEPENDENCIES
49
58
  bundler (~> 1.17)
59
+ byebug
50
60
  dynamocli!
51
61
  rake (~> 10.0)
52
62
  rspec (~> 3.0)
data/dynamocli.gemspec CHANGED
@@ -24,8 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "thor", "~> 0.20"
25
25
  spec.add_dependency "aws-sdk-dynamodb", "~> 1.28"
26
26
  spec.add_dependency "aws-sdk-cloudformation", "~> 1.23"
27
+ spec.add_dependency "tty-logger", "~> 0.1.0"
27
28
 
28
29
  spec.add_development_dependency "bundler", "~> 1.17"
29
30
  spec.add_development_dependency "rake", "~> 10.0"
30
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "byebug"
31
33
  end
@@ -2,10 +2,13 @@
2
2
 
3
3
  require "json"
4
4
  require "yaml"
5
+ require "tty-logger"
5
6
  require "aws-sdk-dynamodb"
6
7
  require "aws-sdk-cloudformation"
7
8
 
8
9
  class Dynamocli::Erase
10
+ LOGGER = TTY::Logger.new
11
+
9
12
  def initialize(table_name:, with_drift: false)
10
13
  @with_drift = with_drift
11
14
  @table_name = table_name
@@ -20,7 +23,7 @@ class Dynamocli::Erase
20
23
 
21
24
  set_stack_information
22
25
  rescue Aws::DynamoDB::Errors::ResourceNotFoundException => e
23
- STDERR.puts "ERROR: #{e.message}"
26
+ LOGGER.error(e.message)
24
27
  exit(42)
25
28
  rescue Aws::CloudFormation::Errors::ValidationError
26
29
  @stack_resources = nil
@@ -29,7 +32,7 @@ class Dynamocli::Erase
29
32
  def start
30
33
  erase_table
31
34
  rescue Aws::CloudFormation::Errors::ValidationError => e
32
- STDERR.puts "ERROR: #{e.message}"
35
+ LOGGER.error(e.message)
33
36
  exit(42)
34
37
  end
35
38
 
@@ -44,6 +47,13 @@ class Dynamocli::Erase
44
47
  schema.delete(:table_arn)
45
48
  schema.delete(:table_id)
46
49
  schema[:provisioned_throughput].delete(:number_of_decreases_today)
50
+ schema[:global_secondary_indexes].each do |gsis|
51
+ gsis.delete(:index_status)
52
+ gsis.delete(:index_size_bytes)
53
+ gsis.delete(:item_count)
54
+ gsis.delete(:index_arn)
55
+ gsis[:provisioned_throughput].delete(:number_of_decreases_today)
56
+ end
47
57
  end
48
58
  end
49
59
 
@@ -54,7 +64,7 @@ class Dynamocli::Erase
54
64
  set_stack
55
65
  set_templates
56
66
  rescue Aws::CloudFormation::Errors::ValidationError => e
57
- STDERR.puts "ERROR: #{e.message}"
67
+ LOGGER.error(e.message)
58
68
  exit(42)
59
69
  end
60
70
 
@@ -78,7 +88,7 @@ class Dynamocli::Erase
78
88
  table = tables.find { |_, v| v["Properties"]["TableName"] == @table_name }
79
89
 
80
90
  if tables.nil?
81
- STDERR.puts "ERROR: table #{@table_name} not found in the #{@stack_name} stack"
91
+ LOGGER.error("table #{@table_name} not found in the #{@stack_name} stack")
82
92
  exit(42)
83
93
  end
84
94
 
@@ -103,21 +113,21 @@ class Dynamocli::Erase
103
113
  end
104
114
 
105
115
  def check_if_user_wants_to_continue_with_recreation
106
- STDOUT.print(
107
- "WARNING: You're going to drop and recreate your #{@table_name} table,\n" \
108
- "do you really want to continue?\n" \
109
- "(anything other than 'y' will cancel) > "
116
+ LOGGER.warn(
117
+ "You're going to drop and recreate your #{@table_name} table,\n" \
118
+ "do you really want to continue?"
110
119
  )
120
+ STDOUT.print("(anything other than 'y' will cancel) > ")
111
121
 
112
122
  confirmation = STDIN.gets.strip
113
123
  return if confirmation == "y"
114
124
 
115
- STDOUT.puts abort_message
125
+ LOGGER.info(abort_message)
116
126
  exit(0)
117
127
  end
118
128
 
119
129
  def abort_message
120
- "INFO: Erase of #{@table_name} table canceled"
130
+ "Erase of #{@table_name} table canceled"
121
131
  end
122
132
 
123
133
  def delete_and_recreate_the_table
@@ -127,17 +137,17 @@ class Dynamocli::Erase
127
137
  end
128
138
 
129
139
  def delete_table
130
- STDOUT.puts "INFO: Deleting the #{@table_name} table"
140
+ LOGGER.info("Deleting the #{@table_name} table")
131
141
 
132
142
  @table.delete
133
143
 
134
- STDOUT.puts "INFO: #{@table_name} table deleted"
144
+ LOGGER.success("#{@table_name} table deleted")
135
145
  end
136
146
 
137
147
  def wait_for_deletion_to_complete
138
148
  waiting_seconds = 0
139
149
  while get_table_status == "DELETING"
140
- STDOUT.puts "INFO: Waiting for deletion to complete"
150
+ LOGGER.info("Waiting for deletion to complete")
141
151
  sleep waiting_seconds += 1
142
152
  end
143
153
  rescue Aws::DynamoDB::Errors::ResourceNotFoundException
@@ -149,24 +159,24 @@ class Dynamocli::Erase
149
159
  end
150
160
 
151
161
  def create_table
152
- STDOUT.puts "INFO: Creating the #{@table_name} table"
162
+ LOGGER.info("Creating the #{@table_name} table")
153
163
 
154
164
  @dynamodb.create_table(@schema)
155
165
 
156
- STDOUT.puts "INFO: #{@table_name} table created"
166
+ LOGGER.success("#{@table_name} table created")
157
167
  end
158
168
 
159
169
  def check_if_user_wants_to_continue_with_deployment
160
- STDOUT.print(
161
- "WARNING: You are going to deploy and redeploy your #{@stack_name} stack\n" \
162
- "to drop and recreate the #{@table_name} table, do you really want to continue?\n" \
163
- "(anything other than 'y' will cancel) > "
170
+ LOGGER.warn(
171
+ "You are going to deploy and redeploy your #{@stack_name} stack\n" \
172
+ "to drop and recreate the #{@table_name} table, do you really want to continue?"
164
173
  )
174
+ STDOUT.print("(anything other than 'y' will cancel) > ")
165
175
 
166
176
  confirmation = STDIN.gets.strip
167
177
  return if confirmation == "y"
168
178
 
169
- STDOUT.puts abort_message
179
+ LOGGER.info(abort_message)
170
180
  exit(0)
171
181
  end
172
182
 
@@ -177,7 +187,7 @@ class Dynamocli::Erase
177
187
  end
178
188
 
179
189
  def deploy_stack_without_the_table
180
- STDOUT.puts "INFO: Deploying the stack without the #{@table_name} table"
190
+ LOGGER.info("Deploying the stack without the #{@table_name} table")
181
191
 
182
192
  @cloudformation.update_stack(
183
193
  stack_name: @stack_name,
@@ -191,7 +201,7 @@ class Dynamocli::Erase
191
201
  tags: @stack.tags.map(&:to_h)
192
202
  )
193
203
 
194
- STDOUT.puts "INFO: Stack deployed without the #{@table_name} table"
204
+ LOGGER.success("Stack deployed without the #{@table_name} table")
195
205
  end
196
206
 
197
207
  def get_stack_policy_body
@@ -201,7 +211,7 @@ class Dynamocli::Erase
201
211
  def wait_for_deployment_to_complete
202
212
  waiting_seconds = 0
203
213
  while get_stack_status != "UPDATE_COMPLETE"
204
- STDOUT.puts "INFO: Waiting for deployment to complete"
214
+ LOGGER.info("Waiting for deployment to complete")
205
215
  sleep waiting_seconds += 1
206
216
  end
207
217
  end
@@ -211,7 +221,7 @@ class Dynamocli::Erase
211
221
  end
212
222
 
213
223
  def deploy_stack_with_the_original_template
214
- STDOUT.puts "INFO: Deploying the stack with the #{@table_name} table"
224
+ LOGGER.info("Deploying the stack with the #{@table_name} table")
215
225
 
216
226
  @cloudformation.update_stack(
217
227
  stack_name: @stack_name,
@@ -225,6 +235,6 @@ class Dynamocli::Erase
225
235
  tags: @stack.tags.map(&:to_h)
226
236
  )
227
237
 
228
- STDOUT.puts "INFO: Stack deployed with the #{@table_name} table"
238
+ LOGGER.success("Stack deployed with the #{@table_name} table")
229
239
  end
230
240
  end
@@ -1,7 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "csv"
4
+ require "tty-logger"
2
5
  require "aws-sdk-dynamodb"
3
6
 
4
7
  class Dynamocli::Import
8
+ LOGGER = TTY::Logger.new
5
9
  SUPPORTED_FILE_FORMATS = ["CSV"]
6
10
 
7
11
  def initialize(file:, table:)
@@ -23,7 +27,7 @@ class Dynamocli::Import
23
27
  when ".csv"
24
28
  records_from_csv(@file)
25
29
  else
26
- STDERR.puts "ERROR: Not supported file format. Only supported file formats are: #{SUPPORTED_FILE_FORMATS}"
30
+ LOGGER.error("Not supported file format. Only supported file formats are: #{SUPPORTED_FILE_FORMATS}")
27
31
  exit(42)
28
32
  end
29
33
  end
@@ -1,3 +1,3 @@
1
1
  module Dynamocli
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamocli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matheus Silva Santos de Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2019-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.23'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-logger
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description:
98
126
  email:
99
127
  - oliveira.matheussilvasantos@gmail.com