vagrant-aws-route53-advoc8 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bcd3ce9aff0ec0f27e4cd6db3741f0141943e970212be8524bd8fbce5f7e3c52
4
+ data.tar.gz: e4c164978b5cf2312a0ef6315e4233793208fa7f3df599b5c1e9c46240934331
5
+ SHA512:
6
+ metadata.gz: 665551f22a03b67dedfae2ed7db025fff426cd628468367dbaa10d4588d2f1180ae42dad5decd4688dfb11c31ec2a709b9a7cda640d06d3dff04baa96c9d1eb5
7
+ data.tar.gz: f4ee875410a683bdf8c79f830dcbe3883377cc2c41c999fef01156a779f5e4f268fa27854045ae122489dd185ed86248f09e5844785079796c2f43f76422b26f
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 oogatta
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
+
@@ -0,0 +1,50 @@
1
+ # Vagrant AWS Route53
2
+
3
+ A Vagrant plugin assigns the public IP of the instance which vagrant-aws provider created to a specific Route 53 record set.
4
+
5
+ Uses AWS-SDK v3
6
+
7
+ ## Assigns the IP when
8
+
9
+ * ```vagrant up``` initial or the halted instance.
10
+
11
+ ## Assigns 0.0.0.0 when
12
+
13
+ * ```vagrant halt```
14
+ * ```vagrant destroy```
15
+
16
+ ### Does not
17
+
18
+ * creates another hosted zone or record set.
19
+ * destroys hosted zone or record set.
20
+
21
+ ## Prerequisite
22
+
23
+ * vagrant-aws > 0.7.2
24
+
25
+ ## Install
26
+
27
+ ```zsh
28
+ $ vagrant plugin install vagrant-aws-route53-rimian
29
+ ```
30
+
31
+ ## Config
32
+
33
+ ```ruby
34
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
35
+ config.vm.box = 'dummy'
36
+ config.ssh.username = 'oogatta'
37
+
38
+ config.vm.provider :aws do |aws, override|
39
+ aws.ami = 'ami'
40
+ aws.access_key_id = 'key_id'
41
+ aws.secret_access_key = 'secret_key'
42
+ aws.region = 'ap-northeast-1'
43
+ aws.instance_type = 't2.medium'
44
+
45
+ override.route53.hosted_zone_id = 'Z1JUXXXXXXXXXX'
46
+ override.route53.record_set = %w(test.oogatta.com. A)
47
+ end
48
+
49
+ end
50
+ ```
@@ -0,0 +1,6 @@
1
+ require 'vagrant-aws-route53-advoc8/plugin'
2
+
3
+ module VagrantPlugins
4
+ module AwsRoute53Advoc8
5
+ end
6
+ end
@@ -0,0 +1,42 @@
1
+ require 'aws-sdk-v3'
2
+
3
+ module VagrantPlugins
4
+ module AwsRoute53Advoc8
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
@@ -0,0 +1,33 @@
1
+ require 'aws-sdk-v1'
2
+ require_relative 'ip_operations'
3
+
4
+ module VagrantPlugins
5
+ module AwsRoute53Advoc8
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, region, secret_access_key = config(environment)
14
+
15
+ return @app.call(environment) if hosted_zone_id.eql?(::Vagrant::Plugin::V2::Config::UNSET_VALUE) || record_set.eql?(::Vagrant::Plugin::V2::Config::UNSET_VALUE)
16
+
17
+ set(
18
+ access_key_id: access_key_id,
19
+ secret_access_key: secret_access_key,
20
+ region: region,
21
+ instance_id: instance_id,
22
+ hosted_zone_id: hosted_zone_id,
23
+ record_set: record_set,
24
+ ) do |instance_id, pubilic_ip, record_set|
25
+ environment[:ui].info("#{instance_id}'s #{pubilic_ip} has been assigned to #{record_set[0]}[#{record_set[1]}]")
26
+ end
27
+
28
+ @app.call(environment)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ require 'aws-sdk-v1'
2
+ require_relative 'ip_operations'
3
+
4
+ module VagrantPlugins
5
+ module AwsRoute53Advoc8
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
+ return @app.call(environment) if hosted_zone_id.eql?(::Vagrant::Plugin::V2::Config::UNSET_VALUE) || record_set.eql?(::Vagrant::Plugin::V2::Config::UNSET_VALUE)
16
+
17
+ set(
18
+ access_key_id: access_key_id,
19
+ secret_access_key: secret_access_key,
20
+ region: region,
21
+ instance_id: instance_id,
22
+ hosted_zone_id: hosted_zone_id,
23
+ record_set: record_set,
24
+ public_ip: '0.0.0.0'
25
+ ) do |instance_id, pubilic_ip, record_set|
26
+ environment[:ui].info("#{pubilic_ip} has been assigned to #{record_set[0]}[#{record_set[1]}]")
27
+ end
28
+
29
+ @app.call(environment)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,21 @@
1
+ require 'vagrant'
2
+
3
+ module VagrantPlugins
4
+ module AwsRoute53Advoc8
5
+ class Config < Vagrant.plugin('2', :config)
6
+ attr_accessor :hosted_zone_id
7
+ attr_accessor :record_set
8
+
9
+ def initialize
10
+ @hosted_zone_id = UNSET_VALUE
11
+ @record_set = UNSET_VALUE
12
+ end
13
+
14
+ def validate(machine)
15
+ errors = _detected_errors
16
+
17
+ { 'AwsRoute53Advoc8' => errors }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ require 'vagrant'
2
+
3
+ module VagrantPlugins
4
+ module AwsRoute53Advoc8
5
+ class Plugin < Vagrant.plugin('2')
6
+ name 'AwsRoute53Advoc8'
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::AwsRoute53Advoc8::Action::SetIp
19
+ hook.after VagrantPlugins::AWS::Action::StartInstance, VagrantPlugins::AwsRoute53Advoc8::Action::SetIp
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::AwsRoute53Advoc8::Action::UnsetIp
25
+ hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsRoute53Advoc8::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::AwsRoute53Advoc8::Action::UnsetIp
31
+ hook.after VagrantPlugins::AWS::Action::TerminateInstance, VagrantPlugins::AwsRoute53Advoc8::Action::UnsetIp
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module AwsRoute53Advoc8
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-aws-route53-advoc8
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Naohiro Oogatta
8
+ - Rimian Perkins
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2021-01-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: aws-sdk
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ description: A Vagrant plugin assigns the IP of the instance which vagrant-aws provider
29
+ created to a specific Route 53 record set.
30
+ email: rimian@advoc8.co
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE
36
+ - README.md
37
+ - lib/vagrant-aws-route53-advoc8.rb
38
+ - lib/vagrant-aws-route53-advoc8/action/ip_operations.rb
39
+ - lib/vagrant-aws-route53-advoc8/action/set_ip.rb
40
+ - lib/vagrant-aws-route53-advoc8/action/unset_ip.rb
41
+ - lib/vagrant-aws-route53-advoc8/config.rb
42
+ - lib/vagrant-aws-route53-advoc8/plugin.rb
43
+ - lib/vagrant-aws-route53-advoc8/version.rb
44
+ homepage: https://github.com/advoc8-co/vagrant-aws-route53-advoc8
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 3.2.3
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Assigns IPs of Vagrant AWS instances to route 53.
67
+ test_files: []