ec2-snapshot-replicator 0.1.1 → 0.1.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
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d607ec7e677d3a32765a1c6ee6f4306973fa6fc
|
4
|
+
data.tar.gz: a89e3f53883a49223df4a47eee74356c7fbf8dac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44a2bd99ea2ae216634f9a3ba4152e36459a9e905a8e1cbaca8c6c00e28f940a609fcffdc1e5716a877421cb8177ea78c3c7a6f3a6edddbceb362720928ea7b1
|
7
|
+
data.tar.gz: e88ef6e7ebd441bb05b1eab082c608fa8995e1677e82fc79179964adcaa80b15bc2ae333dfb10b2cb25071bd2c6f350962787af51b77e7093cbde1034267fc2d
|
@@ -18,8 +18,12 @@ module EC2
|
|
18
18
|
method_option :owner_id, type: :string, required: true
|
19
19
|
method_option :debug, type: :boolean, default: false
|
20
20
|
method_option :once, type: :boolean, default: false
|
21
|
+
method_option :config, type: :string
|
21
22
|
def start
|
22
23
|
config = Config.new
|
24
|
+
if options[:config]
|
25
|
+
config.load_yaml_file(options[:config])
|
26
|
+
end
|
23
27
|
config.load_options(options)
|
24
28
|
|
25
29
|
if options[:once]
|
@@ -1,14 +1,17 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module EC2
|
2
4
|
module Snapshot
|
3
5
|
module Replicator
|
4
|
-
class Config < Struct.new(:source_region, :destination_region, :interval_sec, :delay_deletion_sec, :owner_id, :debug)
|
6
|
+
class Config < Struct.new(:source_region, :destination_region, :interval_sec, :delay_deletion_sec, :owner_id, :debug, :access_key_id, :secret_access_key)
|
7
|
+
def load_yaml_file(path)
|
8
|
+
load_options(YAML.load_file(path))
|
9
|
+
end
|
10
|
+
|
5
11
|
def load_options(options)
|
6
|
-
self.
|
7
|
-
|
8
|
-
|
9
|
-
self.delay_deletion_sec = options[:delay_deletion_sec]
|
10
|
-
self.owner_id = options[:owner_id]
|
11
|
-
self.debug = options[:debug]
|
12
|
+
self.members.each do |member|
|
13
|
+
self[member] = options[member] || options[member.to_s]
|
14
|
+
end
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -12,6 +12,8 @@ module EC2
|
|
12
12
|
def initialize(config)
|
13
13
|
@config = config
|
14
14
|
|
15
|
+
set_credentials
|
16
|
+
|
15
17
|
@source_ec2 = Aws::EC2::Resource.new(region: @config.source_region)
|
16
18
|
@destination_ec2 = Aws::EC2::Resource.new(region: @config.destination_region)
|
17
19
|
end
|
@@ -140,6 +142,17 @@ module EC2
|
|
140
142
|
abort
|
141
143
|
end
|
142
144
|
end
|
145
|
+
|
146
|
+
def set_credentials
|
147
|
+
if @config.access_key_id && @config.secret_access_key
|
148
|
+
Aws.config.update({
|
149
|
+
credentials: Aws::Credentials.new(
|
150
|
+
@config.access_key_id,
|
151
|
+
@config.secret_access_key,
|
152
|
+
),
|
153
|
+
})
|
154
|
+
end
|
155
|
+
end
|
143
156
|
end
|
144
157
|
end
|
145
158
|
end
|