vagrant-aws-dns-synchronous 0.2.6.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3e8d105d608da6b60e62cc397fece6f497b43fbd
4
+ data.tar.gz: b3f3e671eee4c544ce9553f8d13aef9fbc885849
5
+ SHA512:
6
+ metadata.gz: 3aa2a05104e8c282f0204f912f81333676fe236ac2a235ed976835dbddbfc1fc8a45f309e9b7f8153a835a14069008ba3c5db982a7c9fb379dbce46e105d4911
7
+ data.tar.gz: 3e2b521fb3000eb99992ed934826ceb9b3b8fbbf805949f6734600f17e5201b2bfc1c8ab76aeb8ff50bfb4979adb9aa717b40393a7f929cef707a314b7af9f6f
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/~
10
+ /.idea
11
+ /.vagrant
12
+ .DS_Store
13
+ Vagrantfile
14
+ dummy
@@ -0,0 +1,2 @@
1
+ 2.3.0
2
+
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git'
5
+ end
6
+
7
+ group :plugins do
8
+ gemspec
9
+ gem 'vagrant-aws', '~> 0.7.0'
10
+ # gem 'vagrant-aws-dns', path: '.'
11
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nassim Kacha
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,92 @@
1
+ # vagrant-aws-dns
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/vagrant-aws-dns.svg)](https://badge.fury.io/rb/vagrant-aws-dns) [![Dependency Status](https://gemnasium.com/nasskach/vagrant-aws-dns.svg)](https://gemnasium.com/nasskach/vagrant-aws-dns) [![Code Climate](https://codeclimate.com/github/nasskach/vagrant-aws-dns/badges/gpa.svg)](https://codeclimate.com/github/nasskach/vagrant-aws-dns)
4
+
5
+ `vagrant-aws-dns` is a Vagrant plugin that allows you to set up route53 records for instances created using vagrant-aws provider.
6
+
7
+ ## Behaviors
8
+
9
+ * Add/update route53 records on machine up.
10
+ * Remove associated route53 records on machine halt/destroy.
11
+
12
+ ## Release notes
13
+ #### 0.2.3
14
+
15
+ - Downgrade bundler version due to some dependencies problems.
16
+
17
+ #### 0.2.2
18
+
19
+ - Upgrade aws-sdk to 2.3.9.
20
+ - Upgrade bundler to 1.12.
21
+ - Upgrade rake to 11.1.
22
+
23
+ #### 0.2.1
24
+
25
+ - [BUGFIX] hard-coded AWS region ([#1](https://github.com/nasskach/vagrant-aws-dns/issues/1)) - Thanks [hoopesj](https://github.com/hoopesj) for the reporting.
26
+ - Upgrade aws-sdk to 2.2.14.
27
+
28
+ #### 0.2.0
29
+
30
+ - Adding multiple HOSTED_ZONE_ID support.
31
+ - Upgrade aws-sdk to 2.2.9.
32
+
33
+ ## Installation
34
+
35
+ $ vagrant plugin install vagrant-aws-dns
36
+
37
+ ## Usage
38
+
39
+ ### Configuration example
40
+
41
+ ```ruby
42
+ Vagrant.configure("2") do |config|
43
+ config.vm.box = "dummy"
44
+
45
+ config.vm.provider :aws do |aws, override|
46
+ aws.access_key_id = "YOUR KEY"
47
+ aws.secret_access_key = "YOUR SECRET KEY"
48
+ aws.session_token = "SESSION TOKEN"
49
+ aws.keypair_name = "KEYPAIR NAME"
50
+
51
+ aws.ami = "ami-7747d01e"
52
+
53
+ override.ssh.username = "ubuntu"
54
+ override.ssh.private_key_path = "PATH TO YOUR PRIVATE KEY"
55
+
56
+ override.dns.record_sets = [%w(HOSTED_ZONE_ID_1 subdomain.domain1.com A 4.3.2.1), %w(HOSTED_ZONE_ID_2 subdomain.domain2.com A)]
57
+ end
58
+ ```
59
+
60
+ ### record_sets
61
+
62
+ `record_sets` is an array of record sets that are also represented as arrays. Below are some examples:
63
+
64
+ * `%w(HOSTED_ZONE_ID subdomain.domain.com A)` - This will set a record of type `subdomain.domain.com. A <public_ip>`, the `<public_ip>` is auto detected.
65
+ * `%w(HOSTED_ZONE_ID subdomain.domain.com A 4.3.2.1)` - This will set a record of type `subdomain.domain.com. A 4.3.2.1`.
66
+ * `%w(HOSTED_ZONE_ID subdomain.domain.com CNAME domain2.com)` - This will set a record of type `subdomain.domain1.com. CNAME domain2.com.`.
67
+
68
+ The ip may be omitted in which case the correct ip (private/public) will be chosen based on the type of the HOSTED_ZONE_ID.
69
+
70
+ ## FAQ
71
+
72
+ * Why this plugin is not named `vagrant-aws-route53` ?
73
+
74
+ > Unfortunately, that name was already taken by another plugin of the same kind.
75
+
76
+
77
+ * So why develop a new one?
78
+
79
+ > There are several reasons for this: use of new AWS SDK, support of multiple records, support of deleting records on machine halt
80
+ or destroy.
81
+
82
+ ## Contributing
83
+
84
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nasskach/vagrant-aws-dns.
85
+
86
+ ## License
87
+
88
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
89
+
90
+ ## Acknowledgments
91
+
92
+ I want to thank my employer `atHome Group S.A - REA Group` for giving me the opportunity to share this work with the open source community.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ require 'vagrant-aws-dns/plugin'
2
+
3
+
4
+ module VagrantPlugins
5
+ module AwsDns
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'base'
2
+
3
+
4
+ module VagrantPlugins
5
+ module AwsDns
6
+ module Action
7
+ class AddRecord < Base
8
+
9
+ def call(env)
10
+ super env do |hosted_zone_id, record, type, value|
11
+ @machine.ui.info("Configuring DNS record...")
12
+ @aws.add_record(hosted_zone_id, record, type, value)
13
+ @machine.ui.info("Updated DNS record #{record} to point to #{value}.")
14
+ end
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,40 @@
1
+ require 'aws-sdk'
2
+ require_relative '../util/aws_util'
3
+
4
+
5
+ module VagrantPlugins
6
+ module AwsDns
7
+ module Action
8
+ class Base
9
+
10
+ def initialize(app, env)
11
+ @app = app
12
+ @machine = env[:machine]
13
+ end
14
+
15
+ def call(env)
16
+ return @app.call(env) if @machine.config.dns.record_sets.nil?
17
+
18
+ @aws = AwsDns::Util::AwsUtil.new(@machine.provider_config.access_key_id,
19
+ @machine.provider_config.secret_access_key,
20
+ @machine.provider_config.region)
21
+ public_ip = @aws.get_public_ip(@machine.id)
22
+ private_ip = @aws.get_private_ip(@machine.id)
23
+
24
+ @machine.config.dns.record_sets.each do |record_set|
25
+ hosted_zone_id, record, type, value = record_set
26
+
27
+ if @aws.is_private_zone(hosted_zone_id)
28
+ yield hosted_zone_id, record, type, value || private_ip if block_given?
29
+ else
30
+ yield hosted_zone_id, record, type, value || public_ip if block_given?
31
+ end
32
+ end
33
+
34
+ @app.call(env)
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'base'
2
+
3
+
4
+ module VagrantPlugins
5
+ module AwsDns
6
+ module Action
7
+ class RemoveRecord < Base
8
+
9
+ def call(env)
10
+ super env do |hosted_zone_id, record, type, value|
11
+ @aws.remove_record(hosted_zone_id, record, type, value)
12
+ @machine.ui.info("Removing dns record #{record}.")
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ require 'vagrant'
2
+
3
+
4
+ module VagrantPlugins
5
+ module AwsDns
6
+ class Config < Vagrant.plugin('2', :config)
7
+ attr_accessor :hosted_zone_id
8
+ attr_accessor :record_sets
9
+
10
+ def initialize
11
+ @hosted_zone_id = UNSET_VALUE
12
+ @record_sets = UNSET_VALUE
13
+ end
14
+
15
+ def finalize!
16
+ @hosted_zone_id = nil if @hosted_zone_id == UNSET_VALUE
17
+ @record_sets = nil if @record_sets == UNSET_VALUE
18
+ end
19
+
20
+ def validate(machine)
21
+ finalize!
22
+
23
+ errors = _detected_errors
24
+
25
+ { 'AwsDns' => errors }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,48 @@
1
+ require 'vagrant'
2
+
3
+
4
+ module VagrantPlugins
5
+ module AwsDns
6
+ class Plugin < Vagrant.plugin('2')
7
+ name 'aws-dns'
8
+
9
+ description <<-DESC
10
+ A Vagrant plugin that allows you to setup route53 records.
11
+ DESC
12
+
13
+ config :dns do
14
+ require_relative 'config'
15
+ Config
16
+ end
17
+
18
+ action_hook :add_record, :machine_action_up do |hook|
19
+ require_relative 'action/add_record'
20
+ hook.after VagrantPlugins::AWS::Action::RunInstance, VagrantPlugins::AwsDns::Action::AddRecord
21
+ hook.after VagrantPlugins::AWS::Action::StartInstance, VagrantPlugins::AwsDns::Action::AddRecord
22
+ end
23
+
24
+ action_hook :remove_record, :machine_action_halt do |hook|
25
+ require_relative 'action/remove_record'
26
+ hook.after VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::AwsDns::Action::RemoveRecord
27
+ hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsDns::Action::RemoveRecord
28
+ end
29
+
30
+ action_hook :remove_record, :machine_action_destroy do |hook|
31
+ require_relative 'action/remove_record'
32
+ hook.before VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::AwsDns::Action::RemoveRecord
33
+ hook.before VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsDns::Action::RemoveRecord
34
+ end
35
+
36
+ action_hook :add_record, :machine_action_reload do |hook|
37
+ require_relative 'action/remove_record'
38
+ hook.after VagrantPlugins::AWS::Action::StopInstance, VagrantPlugins::AwsDns::Action::RemoveRecord
39
+ hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsDns::Action::RemoveRecord
40
+
41
+ require_relative 'action/add_record'
42
+ hook.after VagrantPlugins::AWS::Action::RunInstance, VagrantPlugins::AwsDns::Action::AddRecord
43
+ hook.after VagrantPlugins::AWS::Action::StartInstance, VagrantPlugins::AwsDns::Action::AddRecord
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,75 @@
1
+ require 'aws-sdk'
2
+
3
+
4
+ module VagrantPlugins
5
+ module AwsDns
6
+ module Util
7
+ class AwsUtil
8
+
9
+ attr_reader :ec2, :route53
10
+
11
+ def initialize(accesskey, secretkey, region)
12
+ credentials = Aws::Credentials.new(accesskey, secretkey)
13
+ @ec2 = Aws::EC2::Client.new(
14
+ region: region,
15
+ credentials: credentials
16
+ )
17
+ @route53 = Aws::Route53::Client.new(
18
+ region: region,
19
+ credentials: credentials
20
+ )
21
+ end
22
+
23
+ def get_public_ip(instance_id)
24
+ @ec2.describe_instances({instance_ids: [instance_id]}).reservations[0].instances[0].public_ip_address
25
+ end
26
+
27
+ def get_private_ip(instance_id)
28
+ @ec2.describe_instances({instance_ids: [instance_id]}).reservations[0].instances[0].private_ip_address
29
+ end
30
+
31
+ def is_private_zone(hosted_zone_id)
32
+ @route53.get_hosted_zone({id: '/hostedzone/' + hosted_zone_id}).hosted_zone.config.private_zone
33
+ end
34
+
35
+ def add_record(hosted_zone_id, record, type, value)
36
+ change = change_record(hosted_zone_id, record, type, value, 'UPSERT')
37
+ wait_for_change(change)
38
+ end
39
+
40
+ def remove_record(hosted_zone_id, record, type, value)
41
+ change_record(hosted_zone_id, record, type, value, 'DELETE')
42
+ end
43
+
44
+ private
45
+
46
+ def change_record(hosted_zone_id, record, type, value, action='CREATE')
47
+ @route53.change_resource_record_sets({
48
+ hosted_zone_id: hosted_zone_id, # required
49
+ change_batch: {
50
+ changes: [
51
+ {
52
+ action: action, # required, accepts CREATE, DELETE, UPSERT
53
+ resource_record_set: {
54
+ name: record, # required
55
+ type: type, # required, accepts SOA, A, TXT, NS, CNAME, MX, PTR, SRV, SPF, AAAA
56
+ ttl: 1,
57
+ resource_records: [
58
+ {
59
+ value: value # required
60
+ }
61
+ ]
62
+ }
63
+ }
64
+ ]
65
+ }
66
+ })
67
+ end
68
+
69
+ def wait_for_change(change_response)
70
+ @route53.wait_until(:resource_record_sets_changed, id: change_response.change_info.id)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,5 @@
1
+ module Vagrant
2
+ module AwsDns
3
+ VERSION = "0.2.6.1"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-aws-dns/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-aws-dns-synchronous"
8
+ spec.version = Vagrant::AwsDns::VERSION
9
+ spec.authors = ["Nassim Kacha"]
10
+ spec.email = ["nassim.kacha@rea-group.com"]
11
+
12
+ spec.summary = %q{A Vagrant plugin that allows you to set up route53 records for instances created using vagrant-aws provider. A temporary fork until https://github.com/nasskach/vagrant-aws-dns/pull/9 is merged.}
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/mikeroll/vagrant-aws-dns"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'aws-sdk', '~> 2.6.44'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 12.0"
26
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-aws-dns-synchronous
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.6.1
5
+ platform: ruby
6
+ authors:
7
+ - Nassim Kacha
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.6.44
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.6.44
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ description: A Vagrant plugin that allows you to set up route53 records for instances
56
+ created using vagrant-aws provider. A temporary fork until https://github.com/nasskach/vagrant-aws-dns/pull/9
57
+ is merged.
58
+ email:
59
+ - nassim.kacha@rea-group.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".ruby-version"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - lib/vagrant-aws-dns.rb
71
+ - lib/vagrant-aws-dns/action/add_record.rb
72
+ - lib/vagrant-aws-dns/action/base.rb
73
+ - lib/vagrant-aws-dns/action/remove_record.rb
74
+ - lib/vagrant-aws-dns/config.rb
75
+ - lib/vagrant-aws-dns/plugin.rb
76
+ - lib/vagrant-aws-dns/util/aws_util.rb
77
+ - lib/vagrant-aws-dns/version.rb
78
+ - vagrant-aws-dns.gemspec
79
+ homepage: https://github.com/mikeroll/vagrant-aws-dns
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.5.2
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: A Vagrant plugin that allows you to set up route53 records for instances
103
+ created using vagrant-aws provider. A temporary fork until https://github.com/nasskach/vagrant-aws-dns/pull/9
104
+ is merged.
105
+ test_files: []