vagrant-aws-route53 0.2.5 → 0.3.0

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: 27ca034304d5c081b77b825600a9eefd5573a1aa
4
- data.tar.gz: f7cc77f63ac3a177a57841a25c1c70cd2991196e
3
+ metadata.gz: 8ff63645e09462a3a38e825f29b31fbeeef34d8d
4
+ data.tar.gz: 16131fe1c2f409121f17b0e759e72f1a59a249c5
5
5
  SHA512:
6
- metadata.gz: f569da2a1f4cf74bb72ab1bac1a40d683663726598f1bf0930d79ba391781c262034127e485e2cce6aa920175b11badb181f7aa513063599e2a38a75327cfb9b
7
- data.tar.gz: 88933a86df6ce7699162406b7aa5fe1a51b63c2c28a32dfdf63346706e3eee9b7c783dbb8f0ebce0ce735e625bc04675a3e8b9144c4a6eb8a351df2fff9e34f4
6
+ metadata.gz: 8d921b4517d6cc060f6d2c528f5049511e3fb6d1c2e10cf16ca0dedf9c2b6249c6f70432d401e126af3c2a8c71077e8948bec68c0b84b2c9b401c4fc3173c185
7
+ data.tar.gz: 366ca879285ab4fbf6b0d17fb40eb1f1dc9aef748d93c53e00fa048e4d8a5327559f6f5ad1f75f74247befb227a4e1c2b0fc1ae5e61445382e10a0477ed93d19
@@ -0,0 +1,42 @@
1
+ require 'aws-sdk'
2
+
3
+ module VagrantPlugins
4
+ module AwsRoute53
5
+ module Action
6
+ class IpOperations
7
+ private
8
+ def config(environment)
9
+ config = environment[:machine].config
10
+ provider_config = environment[:machine].provider_config
11
+
12
+ access_key_id = provider_config.access_key_id
13
+ secret_access_key = provider_config.secret_access_key
14
+ region = provider_config.region
15
+ instance_id = environment[:machine].id
16
+ hosted_zone_id = config.route53.hosted_zone_id
17
+ record_set = config.route53.record_set
18
+
19
+ return access_key_id, hosted_zone_id, instance_id, record_set, region, secret_access_key
20
+ end
21
+
22
+ def set(options)
23
+ ::AWS.config(access_key_id: options[:access_key_id], secret_access_key: options[:secret_access_key], region: options[:region])
24
+
25
+ ec2 = ::AWS.ec2
26
+ public_ip = options[:public_ip] || ec2.instances[options[:instance_id]].public_ip_address
27
+
28
+ record_sets = ::AWS::Route53::HostedZone.new(options[:hosted_zone_id]).rrsets
29
+ record_set = record_sets[*options[:record_set]]
30
+ record_set.resource_records = [{ value: public_ip }]
31
+ record_set.update
32
+
33
+ if block_given?
34
+ yield options[:instance_id], public_ip, options[:record_set]
35
+ end
36
+
37
+ nil
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,23 +1,16 @@
1
1
  require 'aws-sdk'
2
+ require_relative 'ip_operations'
2
3
 
3
4
  module VagrantPlugins
4
5
  module AwsRoute53
5
6
  module Action
6
- class SetIp
7
+ class SetIp < IpOperations
7
8
  def initialize(app, environment)
8
9
  @app = app
9
10
  end
10
11
 
11
12
  def call(environment)
12
- config = environment[:machine].config
13
- provider_config = environment[:machine].provider_config
14
-
15
- access_key_id = provider_config.access_key_id
16
- secret_access_key = provider_config.secret_access_key
17
- region = provider_config.region
18
- instance_id = environment[:machine].id
19
- hosted_zone_id = config.route53.hosted_zone_id
20
- record_set = config.route53.record_set
13
+ access_key_id, hosted_zone_id, instance_id, record_set, region, secret_access_key = config(environment)
21
14
 
22
15
  set(
23
16
  access_key_id: access_key_id,
@@ -32,26 +25,6 @@ module VagrantPlugins
32
25
 
33
26
  @app.call(environment)
34
27
  end
35
-
36
- private
37
-
38
- def set(options)
39
- ::AWS.config(access_key_id: options[:access_key_id], secret_access_key: options[:secret_access_key], region: options[:region])
40
-
41
- ec2 = ::AWS.ec2
42
- public_ip = ec2.instances[options[:instance_id]].public_ip_address
43
-
44
- record_sets = ::AWS::Route53::HostedZone.new(options[:hosted_zone_id]).rrsets
45
- record_set = record_sets[*options[:record_set]]
46
- record_set.resource_records = [{ value: public_ip }]
47
- record_set.update
48
-
49
- if block_given?
50
- yield options[:instance_id], public_ip, options[:record_set]
51
- end
52
-
53
- nil
54
- end
55
28
  end
56
29
  end
57
30
  end
@@ -0,0 +1,32 @@
1
+ require 'aws-sdk'
2
+ require_relative 'ip_operations'
3
+
4
+ module VagrantPlugins
5
+ module AwsRoute53
6
+ module Action
7
+ class UnsetIp < IpOperations
8
+ def initialize(app, environment)
9
+ @app = app
10
+ end
11
+
12
+ def call(environment)
13
+ access_key_id, hosted_zone_id, instance_id, record_set, region, secret_access_key = config(environment)
14
+
15
+ set(
16
+ access_key_id: access_key_id,
17
+ secret_access_key: secret_access_key,
18
+ region: region,
19
+ instance_id: instance_id,
20
+ hosted_zone_id: hosted_zone_id,
21
+ record_set: record_set,
22
+ public_ip: '0.0.0.0'
23
+ ) do |instance_id, pubilic_ip, record_set|
24
+ environment[:ui].info("#{pubilic_ip} has been assigned to #{record_set[0]}[#{record_set[1]}]")
25
+ end
26
+
27
+ @app.call(environment)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -15,9 +15,21 @@ module VagrantPlugins
15
15
 
16
16
  action_hook :assign_ip_to_route53, :machine_action_up do |hook|
17
17
  require_relative './action/set_ip'
18
- hook.after VagrantPlugins::AWS::Action::RunInstance, VagrantPlugins::AwsRoute53::Action::SetIp
18
+ hook.after VagrantPlugins::AWS::Action::RunInstance, VagrantPlugins::AwsRoute53::Action::SetIp
19
19
  hook.after VagrantPlugins::AWS::Action::StartInstance, VagrantPlugins::AwsRoute53::Action::SetIp
20
20
  end
21
+
22
+ action_hook :cancel_ip_from_route53, :machine_action_halt do |hook|
23
+ require_relative './action/unset_ip'
24
+ hook.after VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::AwsRoute53::Action::UnsetIp
25
+ hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsRoute53::Action::UnsetIp
26
+ end
27
+
28
+ action_hook :cancel_ip_from_route53, :machine_action_destroy do |hook|
29
+ require_relative './action/unset_ip'
30
+ hook.after VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::AwsRoute53::Action::UnsetIp
31
+ hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsRoute53::Action::UnsetIp
32
+ end
21
33
  end
22
34
  end
23
35
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module AwsRoute53
3
- VERSION = '0.2.5'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-aws-route53
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naohiro Oogatta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-19 00:00:00.000000000 Z
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -31,7 +31,9 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - lib/vagrant-aws-route53/action/ip_operations.rb
34
35
  - lib/vagrant-aws-route53/action/set_ip.rb
36
+ - lib/vagrant-aws-route53/action/unset_ip.rb
35
37
  - lib/vagrant-aws-route53/config.rb
36
38
  - lib/vagrant-aws-route53/plugin.rb
37
39
  - lib/vagrant-aws-route53/version.rb