vagrant-aws-route53-ng 1.0.6
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 +7 -0
- data/LICENSE +22 -0
- data/README.md +39 -0
- data/lib/vagrant-aws-route53-ng.rb +6 -0
- data/lib/vagrant-aws-route53-ng/action/ip_operations.rb +56 -0
- data/lib/vagrant-aws-route53-ng/action/set_ip.rb +36 -0
- data/lib/vagrant-aws-route53-ng/action/unset_ip.rb +36 -0
- data/lib/vagrant-aws-route53-ng/config.rb +28 -0
- data/lib/vagrant-aws-route53-ng/plugin.rb +41 -0
- data/lib/vagrant-aws-route53-ng/version.rb +5 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c36323404a3103f69fc61872c5726fa6f87a92bf
|
4
|
+
data.tar.gz: 8ceb39553091bf4a38e4c7dcc3d50248f4a97d3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ed53eb06f9f20f34cc57fab539b02905e07b5bcd8937b0ed88f6c9f99ea21f7aaac056ec46b3a1abd4c9fabf47515e21450a73a28927a22ff55a06792875b202
|
7
|
+
data.tar.gz: 553d56a89a4bd4cde4f9e653012fd24cf1b80d88ee72d13320a2eb02fb50ae6e8728776bfe704dfd6e4d4015fbd6f0bb1a866bb27c8e2eb0cb52bb908ecf4cd3
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Naohiro Oogatta, (c) 2015 Ed Ropple
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
vagrant-aws-route53-ng
|
2
|
+
======================
|
3
|
+
|
4
|
+
This Vagrant plugin (forked from Naohiro Oogatta's [vagrant-aws-route53](https://github.com/oogatta/vagrant-aws-route53)) assigns an IP address (either public or private) of a virtual machine created via the `vagrant-aws` provider to a _pre-created_ Route 53 record set. When the instance is created or started from a stopped state, its IP--its public IP by default, unless you set `config.route53.ip_type = :private`--will be applied to the record set's `A` record. When the instance is halted or destroyed, `0.0.0.0` will be applied to the record set.
|
5
|
+
|
6
|
+
## Prerequisite ##
|
7
|
+
|
8
|
+
* vagrant-aws
|
9
|
+
|
10
|
+
## How to Install ##
|
11
|
+
|
12
|
+
```zsh
|
13
|
+
$ vagrant plugin install vagrant-aws-route53-ng
|
14
|
+
```
|
15
|
+
|
16
|
+
## Configuration Example ##
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
20
|
+
config.vm.box = 'dummy'
|
21
|
+
|
22
|
+
config.vm.provider :aws do |aws, override|
|
23
|
+
aws.ami = 'ami-AABBCCDD'
|
24
|
+
aws.access_key_id = ENV['AWS_ACCESS_KEY']
|
25
|
+
aws.secret_access_key = ENV['AWS_SECRET_KEY']
|
26
|
+
aws.region = 'us-east-1'
|
27
|
+
aws.instance_type = 't2.medium'
|
28
|
+
|
29
|
+
override.route53.hosted_zone_id = 'Z1JUXXXXXXXXXX'
|
30
|
+
override.route53.record_set = %w(test.oogatta.com. A)
|
31
|
+
override.route53.ip_type = :public
|
32
|
+
end
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
## Thanks To ##
|
37
|
+
This fork of `vagrant-aws-route53-ng` was built as part of a project at [DraftKings](https://draftkings.com). They're always hiring for quality developers in the Boston region; if you're looking for a new gig, feel free to [contact me](mailto:ed+draftkings@edboxes.com) and I'll happily forward you along.
|
38
|
+
|
39
|
+
`vagrant-aws-route53` was originally developed by Naohiro Oogatta, and approximately 99.875% of the credit for this gizmo goes to him.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'aws-sdk-v1'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Route53NG
|
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
|
+
ip_type = config.route53.ip_type
|
19
|
+
|
20
|
+
return access_key_id, hosted_zone_id, instance_id, record_set, ip_type, region, secret_access_key
|
21
|
+
end
|
22
|
+
|
23
|
+
def set(options)
|
24
|
+
::AWS.config(access_key_id: options[:access_key_id], secret_access_key: options[:secret_access_key], region: options[:region])
|
25
|
+
|
26
|
+
ec2 = ::AWS.ec2
|
27
|
+
instance = ec2.instances[options[:instance_id]]
|
28
|
+
|
29
|
+
ip_address =
|
30
|
+
options[:ip] ||
|
31
|
+
case options[:ip_type]
|
32
|
+
when :public
|
33
|
+
instance.public_ip_address
|
34
|
+
when :private
|
35
|
+
instance.private_ip_address
|
36
|
+
else
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
raise "ip and ip_type are both nil - should never happen?" unless ip_address
|
41
|
+
|
42
|
+
record_sets = ::AWS::Route53::HostedZone.new(options[:hosted_zone_id]).rrsets
|
43
|
+
record_set = record_sets[*options[:record_set]]
|
44
|
+
record_set.resource_records = [{ value: ip_address }]
|
45
|
+
record_set.update
|
46
|
+
|
47
|
+
if block_given?
|
48
|
+
yield options[:instance_id], ip_address, options[:record_set]
|
49
|
+
end
|
50
|
+
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'aws-sdk-v1'
|
2
|
+
require_relative 'ip_operations'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Route53NG
|
6
|
+
module Action
|
7
|
+
class SetIp < 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, ip_type, region, secret_access_key = config(environment)
|
14
|
+
|
15
|
+
return @app.call(environment) \
|
16
|
+
if hosted_zone_id.eql?(::Vagrant::Plugin::V2::Config::UNSET_VALUE) ||
|
17
|
+
record_set.eql?(::Vagrant::Plugin::V2::Config::UNSET_VALUE)
|
18
|
+
|
19
|
+
set(
|
20
|
+
access_key_id: access_key_id,
|
21
|
+
secret_access_key: secret_access_key,
|
22
|
+
region: region,
|
23
|
+
instance_id: instance_id,
|
24
|
+
hosted_zone_id: hosted_zone_id,
|
25
|
+
record_set: record_set,
|
26
|
+
ip_type: ip_type
|
27
|
+
) do |instance_id, ip, record_set|
|
28
|
+
environment[:ui].info("#{instance_id}'s #{ip} has been assigned to #{record_set[0]}[#{record_set[1]}]")
|
29
|
+
end
|
30
|
+
|
31
|
+
@app.call(environment)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'aws-sdk-v1'
|
2
|
+
require_relative 'ip_operations'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Route53NG
|
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, ip_type, region, secret_access_key = config(environment)
|
14
|
+
|
15
|
+
return @app.call(environment) \
|
16
|
+
if hosted_zone_id.eql?(::Vagrant::Plugin::V2::Config::UNSET_VALUE) ||
|
17
|
+
record_set.eql?(::Vagrant::Plugin::V2::Config::UNSET_VALUE)
|
18
|
+
|
19
|
+
set(
|
20
|
+
access_key_id: access_key_id,
|
21
|
+
secret_access_key: secret_access_key,
|
22
|
+
region: region,
|
23
|
+
instance_id: instance_id,
|
24
|
+
hosted_zone_id: hosted_zone_id,
|
25
|
+
record_set: record_set,
|
26
|
+
ip: '0.0.0.0'
|
27
|
+
) do |instance_id, ip, record_set|
|
28
|
+
environment[:ui].info("#{ip} has been assigned to #{record_set[0]}[#{record_set[1]}]")
|
29
|
+
end
|
30
|
+
|
31
|
+
@app.call(environment)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Route53NG
|
5
|
+
class Config < Vagrant.plugin('2', :config)
|
6
|
+
attr_accessor :hosted_zone_id
|
7
|
+
attr_accessor :record_set
|
8
|
+
attr_accessor :ip_type
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@hosted_zone_id = UNSET_VALUE
|
12
|
+
@record_set = UNSET_VALUE
|
13
|
+
@ip_type = UNSET_VALUE
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate(machine)
|
17
|
+
errors = _detected_errors
|
18
|
+
|
19
|
+
if @hosted_zone_id != UNSET_VALUE && @record_set != UNSET_VALUE
|
20
|
+
errors << "config.route53.ip_type must be :public or :private" \
|
21
|
+
unless [ :public, :private ].include?(@ip_type)
|
22
|
+
end
|
23
|
+
|
24
|
+
{ 'Route53NG' => errors }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Route53NG
|
5
|
+
class Plugin < Vagrant.plugin('2')
|
6
|
+
name 'AWS - Route 53 support'
|
7
|
+
|
8
|
+
description <<-DESC
|
9
|
+
DESC
|
10
|
+
|
11
|
+
config :route53 do
|
12
|
+
require_relative './config'
|
13
|
+
Config
|
14
|
+
end
|
15
|
+
|
16
|
+
action_hook :assign_ip_to_route53, :machine_action_up do |hook|
|
17
|
+
require_relative './action/set_ip'
|
18
|
+
hook.after VagrantPlugins::AWS::Action::RunInstance, VagrantPlugins::Route53NG::Action::SetIp
|
19
|
+
hook.after VagrantPlugins::AWS::Action::StartInstance, VagrantPlugins::Route53NG::Action::SetIp
|
20
|
+
end
|
21
|
+
|
22
|
+
action_hook :assign_ip_to_route53, :machine_action_resume do |hook|
|
23
|
+
require_relative './action/set_ip'
|
24
|
+
hook.after VagrantPlugins::AWS::Action::RunInstance, VagrantPlugins::Route53NG::Action::SetIp
|
25
|
+
hook.after VagrantPlugins::AWS::Action::StartInstance, VagrantPlugins::Route53NG::Action::SetIp
|
26
|
+
end
|
27
|
+
|
28
|
+
action_hook :cancel_ip_from_route53, :machine_action_halt do |hook|
|
29
|
+
require_relative './action/unset_ip'
|
30
|
+
hook.after VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::Route53NG::Action::UnsetIp
|
31
|
+
hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::Route53NG::Action::UnsetIp
|
32
|
+
end
|
33
|
+
|
34
|
+
action_hook :cancel_ip_from_route53, :machine_action_destroy do |hook|
|
35
|
+
require_relative './action/unset_ip'
|
36
|
+
hook.after VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::Route53NG::Action::UnsetIp
|
37
|
+
hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::Route53NG::Action::UnsetIp
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-aws-route53-ng
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ed Ropple
|
8
|
+
- Naohiro Oogatta
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: aws-sdk-v1
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description: A Vagrant plugin assigns the IP of the instance which vagrant-aws provider
|
43
|
+
created to a specific Route 53 record set.
|
44
|
+
email:
|
45
|
+
- ed+vagrant-route53@edboxes.com
|
46
|
+
- oogatta@gmail.com
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- lib/vagrant-aws-route53-ng/action/ip_operations.rb
|
52
|
+
- lib/vagrant-aws-route53-ng/action/set_ip.rb
|
53
|
+
- lib/vagrant-aws-route53-ng/action/unset_ip.rb
|
54
|
+
- lib/vagrant-aws-route53-ng/config.rb
|
55
|
+
- lib/vagrant-aws-route53-ng/plugin.rb
|
56
|
+
- lib/vagrant-aws-route53-ng/version.rb
|
57
|
+
- lib/vagrant-aws-route53-ng.rb
|
58
|
+
- LICENSE
|
59
|
+
- README.md
|
60
|
+
homepage: https://github.com/edboxes/vagrant-aws-route53-ng
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.0.14
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Assigns IPs of Vagrant AWS instances to route 53.
|
84
|
+
test_files: []
|