ec2-snapshot-replicator 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 9cfd0af2c25a8b0e4fc0043bb413b9e6539c4962
4
- data.tar.gz: 977cb62e04895574d962eabce9a6348ac5e9801a
3
+ metadata.gz: 9d607ec7e677d3a32765a1c6ee6f4306973fa6fc
4
+ data.tar.gz: a89e3f53883a49223df4a47eee74356c7fbf8dac
5
5
  SHA512:
6
- metadata.gz: 6fcdac97d59107984141eaf5ca22d837568e1d1729ffb2b63286b9e67d7c06f81ff62b1f33207711852eb1be6a13dc9241767157d5b830afa0a8ef3a1b8e3e7a
7
- data.tar.gz: f687938b4176ce9d5567590795ef01e4efc6d5c8764ec6743e456806096b81d4aa6d0793b6867845bef177326f1f3e8b66fccd5cf02408a12155d3c35d79d543
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.source_region = options[:source_region]
7
- self.destination_region = options[:destination_region]
8
- self.interval_sec = options[:interval_sec]
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
@@ -1,7 +1,7 @@
1
1
  module EC2
2
2
  module Snapshot
3
3
  module Replicator
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2-snapshot-replicator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai