cfn_manage 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynamodb_start_stop_handler.rb +53 -0
- data/lib/rds_start_stop_handler.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: e3c4afd538389130731a726436500698694da3f0
|
4
|
+
data.tar.gz: 13cdd8ba876f30ffdc270041a54f84166bf53495
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3b3804202de03e659d18b0be7dcd0c87d9500fb7233f718ec0c29d076ead3b8291888147baaec89122edafa54a3443189199361309cdf0b20933f59bf56b19a
|
7
|
+
data.tar.gz: 0ce6bf7c84d5effe320377d02b2643e43f0a4a2c3b5629e4b42eca85bac3d5d50a92b114a848e6654a147aaf09dcbc398de6ad61efbdd0e335c832831a934f3d
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative '../lib/aws_credentials'
|
2
|
+
|
3
|
+
module Base2
|
4
|
+
|
5
|
+
class DynamoDbStartStopHandler
|
6
|
+
|
7
|
+
@table
|
8
|
+
@table_name
|
9
|
+
@gsi_names
|
10
|
+
|
11
|
+
def initialize(table_name)
|
12
|
+
credentials = Base2::AWSCredentials.get_session_credentials("stoprun_#{instance_id}")
|
13
|
+
ec2_client = Aws::DynamoDB::Client.new(credentials: credentials)
|
14
|
+
@table = Aws::DynamoDB::Resource.new(client: ec2_client).table(table_name)
|
15
|
+
@table_name = table_name
|
16
|
+
@table.global_secondary_indexes.each do |gsi|
|
17
|
+
@gsi_names << gsi.index_name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def start(configuration)
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def stop
|
26
|
+
configuration = {
|
27
|
+
read_capacity: @table.provisioned_throughput.read_capacity_units,
|
28
|
+
write_capacity: @table.provisioned_throughput.write_capacity_units
|
29
|
+
}
|
30
|
+
|
31
|
+
$log.info("Current dynamo table #{@table.name} capacity: #{configuration}")
|
32
|
+
|
33
|
+
# check if environment vairable set for
|
34
|
+
if ENV.key? ('cfn_manage_dynamodb_stop_capacity')
|
35
|
+
stop_capacity = ENV['cfn_manage_dynamodb_stop_capacity'].to_i
|
36
|
+
|
37
|
+
$log.info("Downsizing read/write capacity to #{stop_capacity}")
|
38
|
+
@table.update({
|
39
|
+
provisioned_throughput: {
|
40
|
+
read_capacity_units: stop_capacity, # required
|
41
|
+
write_capacity_units: stop_capacity, # required
|
42
|
+
}
|
43
|
+
})
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
configuration
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -89,7 +89,7 @@ module Base2
|
|
89
89
|
@rds_instance.modify({ multi_az: multi_az, apply_immediately: true })
|
90
90
|
# allow half an hour for instance to be converted
|
91
91
|
wait_states = %w(modifying available)
|
92
|
-
|
92
|
+
wait_rds_instance_states( wait_states)
|
93
93
|
end
|
94
94
|
|
95
95
|
def wait_rds_instance_states(wait_states)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn_manage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Base2Services
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-11-
|
12
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/cf_common.rb
|
48
48
|
- lib/cf_progress_tracker.rb
|
49
49
|
- lib/cf_start_stop_environment.rb
|
50
|
+
- lib/dynamodb_start_stop_handler.rb
|
50
51
|
- lib/ec2_start_stop_handler.rb
|
51
52
|
- lib/rds_start_stop_handler.rb
|
52
53
|
- lib/start_stop_handler_factory.rb
|