route53_auto 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a4a2450ef5bb5334d84b2def24fb8de5236ff433
4
+ data.tar.gz: 85c661136d01ccdb2ab6650ef56f444c83127a38
5
+ SHA512:
6
+ metadata.gz: 3fb98911f33b81c7d749e8ac495478162571f5cd6c2e92f911c8cc6dc1a3666655c9058f8b028b67b882d07a51e5bf0644d5a921937b7cb3f2bb2c7aa0255fea
7
+ data.tar.gz: cc62b8ef410e2ba9314f69dfae33f36b3550ac90ad8f8ed413a4a5bcdda3247f645329f5d9465aeedbfdfc57b8220986294ca0a810a1f07cc6caac33f83e8d4b
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ route53_auto-0.1.0.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.3
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in route53_auto.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 TODO: Write your name
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.
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # Route53Auto
2
+
3
+ Welcome to Route53Auto.
4
+ The purpose of this gem is to automatically aliase your dns with your domain name with AWS.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'route53_auto'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install route53_auto
21
+
22
+ ## Configuration
23
+
24
+ **First Method**
25
+
26
+ Add as environment variables:
27
+
28
+ `AMAZON_REGION = 'your-region-1'`
29
+
30
+ `AMAZON_ACCESS_KEY = 'your-access-key'`
31
+
32
+ `AMAZON_SECRET_ACCESS = 'your-secret-access-key'`
33
+
34
+
35
+ **Second method**
36
+
37
+ If you have your credentials stored here `~/.aws/credentials`
38
+ create a profile called `ec2`
39
+
40
+ And prototype it like this ->
41
+ ```
42
+ [ec2]
43
+ aws_access_key_id = youraccesskey
44
+ aws_secret_access_key = yoursecretaccesskey
45
+ ```
46
+ **If your ec2 server is located somewhere else than `eu-west-1`, please fill up `AMAZON_REGION` variable**
47
+
48
+
49
+ ## Usage
50
+
51
+ Make sure you have auto-scaling disabled on your ec2 instance.
52
+
53
+
54
+ Use your instance-id and your domaine name to link `route = Route53.new('i-yourid', 'your.domain-name.com')`
55
+
56
+ It will aliase your dns with your domaine name
57
+
58
+
59
+ ### Pro-Tips
60
+
61
+ You can also use any route53-client command you want by using `route.client` variable.
62
+ Usable methods are here -> http://docs.aws.amazon.com/sdkforruby/api/Aws/Route53/Client.html
63
+
64
+ ## Development
65
+
66
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
67
+
68
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
69
+
70
+ ## Contributing
71
+
72
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Kokiwi/route53_auto. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
73
+
74
+
75
+ ## License
76
+
77
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
78
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "route53_auto"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module Route53Auto
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,47 @@
1
+ require "route53_auto/version"
2
+ require "ec2_switcher"
3
+
4
+ class Route53 < Switcher
5
+
6
+ attr_accessor :client
7
+ attr_accessor :r53
8
+
9
+ def initialize(id, domain_name)
10
+ super(id)
11
+ puts "\nswitcher initialized" if @switcher
12
+ @client = r53_client_connect
13
+ puts 'Client auth successfull' if @client
14
+ @r53 = auto_change(domain_name)
15
+ puts 'r53 client auth successfull' if @r53
16
+ end
17
+
18
+ def r53_client_connect
19
+ Aws::Route53::Client.new(region: @region, credentials: @credentials)
20
+ end
21
+
22
+ def reload
23
+ @client = self.r53_client_connect
24
+ end
25
+
26
+ private
27
+
28
+ def auto_change(domain_name)
29
+ @client.change_resource_record_sets({
30
+ hosted_zone_id: @client.list_hosted_zones[:hosted_zones][0][:id],
31
+ change_batch: {
32
+ changes: [{
33
+ action: "UPSERT",
34
+ resource_record_set: {
35
+ name: domain_name,
36
+ type: "CNAME",
37
+ ttl: 60,
38
+ resource_records: [{
39
+ value: @ec2.public_dns_name
40
+ }]
41
+ }
42
+ }]
43
+ }
44
+ })
45
+ end
46
+
47
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'route53_auto/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "route53_auto"
8
+ spec.version = Route53Auto::VERSION
9
+ spec.authors = ["Kevin LEIBA"]
10
+ spec.email = ["kleiba@student.42.fr"]
11
+
12
+ spec.summary = %q{Use this gem to alias a dns to a domain name with AWS}
13
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "http://bubblz.net"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+
34
+ spec.add_dependency 'aws-sdk', '~> 2'
35
+ spec.add_dependency 'ec2_switcher', '~> 0.1.2'
36
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: route53_auto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Kevin LEIBA
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aws-sdk
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ec2_switcher
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.1.2
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.2
83
+ description:
84
+ email:
85
+ - kleiba@student.42.fr
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/route53_auto.rb
101
+ - lib/route53_auto/version.rb
102
+ - route53_auto.gemspec
103
+ homepage: http://bubblz.net
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.5.1
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Use this gem to alias a dns to a domain name with AWS
127
+ test_files: []